From 6e1ec4c5da6da4bd301080a8c35f8483d89e095f Mon Sep 17 00:00:00 2001 From: lain Date: Mon, 26 Aug 2019 16:29:51 -0500 Subject: [PATCH 001/154] ActivityPub: Basic EmojiReactions. --- lib/pleroma/web/activity_pub/activity_pub.ex | 10 +++++++++ lib/pleroma/web/activity_pub/utils.ex | 10 +++++++++ test/web/activity_pub/activity_pub_test.exs | 22 ++++++++++++++++++++ 3 files changed, 42 insertions(+) diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex index 172c952d4..a6088a012 100644 --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@ -312,6 +312,16 @@ def update(%{to: to, cc: cc, actor: actor, object: object} = params) do end end + def react_with_emoji(user, object, emoji, options \\ []) do + with local <- Keyword.get(options, :local, true), + activity_id <- Keyword.get(options, :activity_id, nil), + is_emoji?(emoji), + reaction_data <- make_emoji_reaction_data(user, object, emoji, activity_id), + {:ok, activity} <- insert(reaction_data, local) do + {:ok, activity, object} + end + end + # TODO: This is weird, maybe we shouldn't check here if we can make the activity. def like( %User{ap_id: ap_id} = user, diff --git a/lib/pleroma/web/activity_pub/utils.ex b/lib/pleroma/web/activity_pub/utils.ex index 1c3058658..d57830da3 100644 --- a/lib/pleroma/web/activity_pub/utils.ex +++ b/lib/pleroma/web/activity_pub/utils.ex @@ -296,6 +296,16 @@ def get_object_likes(%{data: %{"id" => id}}) do Repo.all(query) end + def is_emoji?(emoji) do + String.length(emoji) == 1 + end + + def make_emoji_reaction_data(user, object, emoji, activity_id) do + make_like_data(user, object, activity_id) + |> Map.put("type", "EmojiReaction") + |> Map.put("content", emoji) + end + def make_like_data( %User{ap_id: ap_id} = actor, %{data: %{"actor" => object_actor_id, "id" => id}} = object, diff --git a/test/web/activity_pub/activity_pub_test.exs b/test/web/activity_pub/activity_pub_test.exs index 1515f4eb6..cf93f624a 100644 --- a/test/web/activity_pub/activity_pub_test.exs +++ b/test/web/activity_pub/activity_pub_test.exs @@ -675,6 +675,28 @@ test "returns reblogs for users for whom reblogs have not been muted" do end end + describe "react to an object" do + test "adds an emoji reaction activity to the db" do + user = insert(:user) + reactor = insert(:user) + {:ok, activity} = CommonAPI.post(user, %{"status" => "YASSSS queen slay"}) + assert object = Object.normalize(activity) + + {:ok, reaction_activity, object} = ActivityPub.react_with_emoji(reactor, object, "🔥") + + assert reaction_activity + + assert reaction_activity.data["actor"] == reactor.ap_id + assert reaction_activity.data["type"] == "EmojiReaction" + assert reaction_activity.data["content"] == "🔥" + assert reaction_activity.data["object"] == object.data["id"] + assert reaction_activity.data["to"] == [User.ap_followers(reactor), activity.data["actor"]] + assert reaction_activity.data["context"] == object.data["context"] + # assert object.data["reaction_count"] == 1 + # assert object.data["reactions"] == [user.ap_id] + end + end + describe "like an object" do test "adds a like activity to the db" do note_activity = insert(:note_activity) From a0b21c89284304bea90f2774f17d5b2b7b3c1359 Mon Sep 17 00:00:00 2001 From: lain Date: Mon, 26 Aug 2019 16:47:31 -0500 Subject: [PATCH 002/154] Transmogrifier: Handle incoming emoji reactions. --- .../web/activity_pub/transmogrifier.ex | 21 +++++++++++++ test/fixtures/emoji-reaction.json | 30 +++++++++++++++++++ test/web/activity_pub/transmogrifier_test.exs | 18 +++++++++++ 3 files changed, 69 insertions(+) create mode 100644 test/fixtures/emoji-reaction.json diff --git a/lib/pleroma/web/activity_pub/transmogrifier.ex b/lib/pleroma/web/activity_pub/transmogrifier.ex index 36340a3a1..9132df8cb 100644 --- a/lib/pleroma/web/activity_pub/transmogrifier.ex +++ b/lib/pleroma/web/activity_pub/transmogrifier.ex @@ -572,6 +572,27 @@ def handle_incoming( end end + def handle_incoming( + %{ + "type" => "EmojiReaction", + "object" => object_id, + "actor" => _actor, + "id" => id, + "content" => emoji + } = data, + _options + ) do + with actor <- Containment.get_actor(data), + {:ok, %User{} = actor} <- User.get_or_fetch_by_ap_id(actor), + {:ok, object} <- get_obj_helper(object_id), + {:ok, activity, _object} <- + ActivityPub.react_with_emoji(actor, object, emoji, activity_id: id, local: false) do + {:ok, activity} + else + _e -> :error + end + end + def handle_incoming( %{"type" => "Announce", "object" => object_id, "actor" => _actor, "id" => id} = data, _options diff --git a/test/fixtures/emoji-reaction.json b/test/fixtures/emoji-reaction.json new file mode 100644 index 000000000..3812e43ad --- /dev/null +++ b/test/fixtures/emoji-reaction.json @@ -0,0 +1,30 @@ +{ + "type": "EmojiReaction", + "signature": { + "type": "RsaSignature2017", + "signatureValue": "fdxMfQSMwbC6wP6sh6neS/vM5879K67yQkHTbiT5Npr5wAac0y6+o3Ij+41tN3rL6wfuGTosSBTHOtta6R4GCOOhCaCSLMZKypnp1VltCzLDoyrZELnYQIC8gpUXVmIycZbREk22qWUe/w7DAFaKK4UscBlHDzeDVcA0K3Se5Sluqi9/Zh+ldAnEzj/rSEPDjrtvf5wGNf3fHxbKSRKFt90JvKK6hS+vxKUhlRFDf6/SMETw+EhwJSNW4d10yMUakqUWsFv4Acq5LW7l+HpYMvlYY1FZhNde1+uonnCyuQDyvzkff8zwtEJmAXC4RivO/VVLa17SmqheJZfI8oluVg==", + "creator": "http://mastodon.example.org/users/admin#main-key", + "created": "2018-02-17T18:57:49Z" + }, + "object": "http://localtesting.pleroma.lol/objects/eb92579d-3417-42a8-8652-2492c2d4f454", + "content": "👌", + "nickname": "lain", + "id": "http://mastodon.example.org/users/admin#reactions/2", + "actor": "http://mastodon.example.org/users/admin", + "@context": [ + "https://www.w3.org/ns/activitystreams", + "https://w3id.org/security/v1", + { + "toot": "http://joinmastodon.org/ns#", + "sensitive": "as:sensitive", + "ostatus": "http://ostatus.org#", + "movedTo": "as:movedTo", + "manuallyApprovesFollowers": "as:manuallyApprovesFollowers", + "inReplyToAtomUri": "ostatus:inReplyToAtomUri", + "conversation": "ostatus:conversation", + "atomUri": "ostatus:atomUri", + "Hashtag": "as:Hashtag", + "Emoji": "toot:Emoji" + } + ] +} diff --git a/test/web/activity_pub/transmogrifier_test.exs b/test/web/activity_pub/transmogrifier_test.exs index 0661d5d7c..6df707370 100644 --- a/test/web/activity_pub/transmogrifier_test.exs +++ b/test/web/activity_pub/transmogrifier_test.exs @@ -311,6 +311,24 @@ test "it works for incoming likes" do assert data["object"] == activity.data["object"] end + test "it works for incoming emoji reactions" do + user = insert(:user) + {:ok, activity} = CommonAPI.post(user, %{"status" => "hello"}) + + data = + File.read!("test/fixtures/emoji-reaction.json") + |> Poison.decode!() + |> Map.put("object", activity.data["object"]) + + {:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data) + + assert data["actor"] == "http://mastodon.example.org/users/admin" + assert data["type"] == "EmojiReaction" + assert data["id"] == "http://mastodon.example.org/users/admin#reactions/2" + assert data["object"] == activity.data["object"] + assert data["content"] == "👌" + end + test "it returns an error for incoming unlikes wihout a like activity" do user = insert(:user) {:ok, activity} = CommonAPI.post(user, %{"status" => "leave a like pls"}) From b770ed1d9940230d4bd97113abdc220ca7d8eb1a Mon Sep 17 00:00:00 2001 From: lain Date: Tue, 27 Aug 2019 17:56:28 -0500 Subject: [PATCH 003/154] CommonAPI: Support emoji reactions. --- lib/pleroma/web/common_api/common_api.ex | 10 ++++++++++ test/web/common_api/common_api_test.exs | 14 ++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/lib/pleroma/web/common_api/common_api.ex b/lib/pleroma/web/common_api/common_api.ex index 5faddc9f4..3e1aa4818 100644 --- a/lib/pleroma/web/common_api/common_api.ex +++ b/lib/pleroma/web/common_api/common_api.ex @@ -123,6 +123,16 @@ def unfavorite(id_or_ap_id, user) do end end + def react_with_emoji(id, user, emoji) do + with %Activity{} = activity <- Activity.get_by_id(id), + object <- Object.normalize(activity) do + ActivityPub.react_with_emoji(user, object, emoji) + else + _ -> + {:error, dgettext("errors", "Could not add reaction emoji")} + end + end + def vote(user, object, choices) do with "Question" <- object.data["type"], {:author, false} <- {:author, object.data["actor"] == user.ap_id}, diff --git a/test/web/common_api/common_api_test.exs b/test/web/common_api/common_api_test.exs index f28a66090..7cb1202fc 100644 --- a/test/web/common_api/common_api_test.exs +++ b/test/web/common_api/common_api_test.exs @@ -222,6 +222,20 @@ test "it can handle activities that expire" do end describe "reactions" do + test "reacting to a status with an emoji" do + user = insert(:user) + other_user = insert(:user) + + {:ok, activity} = CommonAPI.post(other_user, %{"status" => "cofe"}) + + {:ok, reaction, _} = CommonAPI.react_with_emoji(activity.id, user, "👍") + + assert reaction.data["actor"] == user.ap_id + assert reaction.data["content"] == "👍" + + # TODO: test error case. + end + test "repeating a status" do user = insert(:user) other_user = insert(:user) From 9bc12b88b3b4b90ee1b55ebf49a13665a751ef1a Mon Sep 17 00:00:00 2001 From: lain Date: Tue, 3 Sep 2019 16:50:04 -0500 Subject: [PATCH 004/154] ActivityPub: Save emoji reactions in object. --- lib/pleroma/web/activity_pub/activity_pub.ex | 3 ++- lib/pleroma/web/activity_pub/utils.ex | 27 +++++++++++++++++++- test/web/activity_pub/activity_pub_test.exs | 4 +-- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex index 532db17c4..6cd168427 100644 --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@ -317,7 +317,8 @@ def react_with_emoji(user, object, emoji, options \\ []) do activity_id <- Keyword.get(options, :activity_id, nil), is_emoji?(emoji), reaction_data <- make_emoji_reaction_data(user, object, emoji, activity_id), - {:ok, activity} <- insert(reaction_data, local) do + {:ok, activity} <- insert(reaction_data, local), + {:ok, object} <- add_emoji_reaction_to_object(activity, object) do {:ok, activity, object} end end diff --git a/lib/pleroma/web/activity_pub/utils.ex b/lib/pleroma/web/activity_pub/utils.ex index 32e22d8d7..1e6a67deb 100644 --- a/lib/pleroma/web/activity_pub/utils.ex +++ b/lib/pleroma/web/activity_pub/utils.ex @@ -321,10 +321,21 @@ def make_like_data( @spec update_element_in_object(String.t(), list(any), Object.t()) :: {:ok, Object.t()} | {:error, Ecto.Changeset.t()} def update_element_in_object(property, element, object) do + length = + if is_map(element) do + element + |> Map.values() + |> List.flatten() + |> length() + else + element + |> length() + end + data = Map.merge( object.data, - %{"#{property}_count" => length(element), "#{property}s" => element} + %{"#{property}_count" => length, "#{property}s" => element} ) object @@ -332,6 +343,20 @@ def update_element_in_object(property, element, object) do |> Object.update_and_set_cache() end + @spec add_emoji_reaction_to_object(Activity.t(), Object.t()) :: + {:ok, Object.t()} | {:error, Ecto.Changeset.t()} + + def add_emoji_reaction_to_object( + %Activity{data: %{"content" => emoji, "actor" => actor}}, + object + ) do + reactions = object.data["reactions"] || %{} + emoji_actors = reactions[emoji] || [] + new_emoji_actors = [actor | emoji_actors] |> Enum.uniq() + new_reactions = Map.put(reactions, emoji, new_emoji_actors) + update_element_in_object("reaction", new_reactions, object) + end + @spec add_like_to_object(Activity.t(), Object.t()) :: {:ok, Object.t()} | {:error, Ecto.Changeset.t()} def add_like_to_object(%Activity{data: %{"actor" => actor}}, object) do diff --git a/test/web/activity_pub/activity_pub_test.exs b/test/web/activity_pub/activity_pub_test.exs index b168e85a0..67dfb9394 100644 --- a/test/web/activity_pub/activity_pub_test.exs +++ b/test/web/activity_pub/activity_pub_test.exs @@ -694,8 +694,8 @@ test "adds an emoji reaction activity to the db" do assert reaction_activity.data["object"] == object.data["id"] assert reaction_activity.data["to"] == [User.ap_followers(reactor), activity.data["actor"]] assert reaction_activity.data["context"] == object.data["context"] - # assert object.data["reaction_count"] == 1 - # assert object.data["reactions"] == [user.ap_id] + assert object.data["reaction_count"] == 1 + assert object.data["reactions"]["🔥"] == [reactor.ap_id] end end From 99ea990a16a417cd316b3464ef380746171ecb55 Mon Sep 17 00:00:00 2001 From: lain Date: Wed, 4 Sep 2019 12:20:35 -0500 Subject: [PATCH 005/154] PleromaAPIController: Add emoji reactions. --- .../web/pleroma_api/pleroma_api_controller.ex | 11 +++++++++++ lib/pleroma/web/router.ex | 1 + .../pleroma_api/pleroma_api_controller_test.exs | 15 +++++++++++++++ 3 files changed, 27 insertions(+) diff --git a/lib/pleroma/web/pleroma_api/pleroma_api_controller.ex b/lib/pleroma/web/pleroma_api/pleroma_api_controller.ex index b6d2bf86b..740ea4747 100644 --- a/lib/pleroma/web/pleroma_api/pleroma_api_controller.ex +++ b/lib/pleroma/web/pleroma_api/pleroma_api_controller.ex @@ -7,11 +7,22 @@ defmodule Pleroma.Web.PleromaAPI.PleromaAPIController do import Pleroma.Web.ControllerHelper, only: [add_link_headers: 7] + alias Pleroma.Activity alias Pleroma.Conversation.Participation alias Pleroma.Web.ActivityPub.ActivityPub + alias Pleroma.Web.CommonAPI alias Pleroma.Web.MastodonAPI.ConversationView alias Pleroma.Web.MastodonAPI.StatusView + def react_with_emoji(%{assigns: %{user: user}} = conn, %{"id" => activity_id, "emoji" => emoji}) do + with {:ok, _activity, _object} <- CommonAPI.react_with_emoji(activity_id, user, emoji), + activity = Activity.get_by_id(activity_id) do + conn + |> put_view(StatusView) + |> render("status.json", %{activity: activity, for: user, as: :activity}) + end + end + def conversation(%{assigns: %{user: user}} = conn, %{"id" => participation_id}) do with %Participation{} = participation <- Participation.get(participation_id), true <- user.id == participation.user_id do diff --git a/lib/pleroma/web/router.ex b/lib/pleroma/web/router.ex index 969dc66fd..6cca54211 100644 --- a/lib/pleroma/web/router.ex +++ b/lib/pleroma/web/router.ex @@ -277,6 +277,7 @@ defmodule Pleroma.Web.Router do scope [] do pipe_through(:oauth_write) patch("/conversations/:id", PleromaAPIController, :update_conversation) + post("/statuses/:id/react_with_emoji", PleromaAPIController, :react_with_emoji) end end diff --git a/test/web/pleroma_api/pleroma_api_controller_test.exs b/test/web/pleroma_api/pleroma_api_controller_test.exs index ed6b79727..aab0c774e 100644 --- a/test/web/pleroma_api/pleroma_api_controller_test.exs +++ b/test/web/pleroma_api/pleroma_api_controller_test.exs @@ -11,6 +11,21 @@ defmodule Pleroma.Web.PleromaAPI.PleromaAPIControllerTest do import Pleroma.Factory + test "POST /api/v1/pleroma/statuses/:id/react_with_emoji", %{conn: conn} do + user = insert(:user) + other_user = insert(:user) + + {:ok, activity} = CommonAPI.post(user, %{"status" => "#cofe"}) + + result = + conn + |> assign(:user, other_user) + |> post("/api/v1/pleroma/statuses/#{activity.id}/react_with_emoji", %{"emoji" => "☕"}) + + assert %{"id" => id} = json_response(result, 200) + assert to_string(activity.id) == id + end + test "/api/v1/pleroma/conversations/:id", %{conn: conn} do user = insert(:user) other_user = insert(:user) From 05e9776517498370ab8f7b7afa0408f6ee979844 Mon Sep 17 00:00:00 2001 From: lain Date: Thu, 12 Sep 2019 18:48:25 +0200 Subject: [PATCH 006/154] PleromaAPIController: Add endpoint to fetch emoji reactions. --- .../web/pleroma_api/pleroma_api_controller.ex | 28 +++++++++++++++++++ lib/pleroma/web/router.ex | 6 ++++ .../pleroma_api_controller_test.exs | 25 +++++++++++++++++ 3 files changed, 59 insertions(+) diff --git a/lib/pleroma/web/pleroma_api/pleroma_api_controller.ex b/lib/pleroma/web/pleroma_api/pleroma_api_controller.ex index 740ea4747..bb090d37f 100644 --- a/lib/pleroma/web/pleroma_api/pleroma_api_controller.ex +++ b/lib/pleroma/web/pleroma_api/pleroma_api_controller.ex @@ -8,12 +8,40 @@ defmodule Pleroma.Web.PleromaAPI.PleromaAPIController do import Pleroma.Web.ControllerHelper, only: [add_link_headers: 7] alias Pleroma.Activity + alias Pleroma.Object + alias Pleroma.User alias Pleroma.Conversation.Participation alias Pleroma.Web.ActivityPub.ActivityPub alias Pleroma.Web.CommonAPI + alias Pleroma.Web.MastodonAPI.AccountView alias Pleroma.Web.MastodonAPI.ConversationView alias Pleroma.Web.MastodonAPI.StatusView + def emoji_reactions_by(%{assigns: %{user: user}} = conn, %{"id" => activity_id}) do + with %Activity{} = activity <- Activity.get_by_id_with_object(activity_id), + %Object{data: %{"reactions" => emoji_reactions}} <- Object.normalize(activity) do + reactions = + Enum.reduce(emoji_reactions, %{}, fn {emoji, users}, res -> + users = + users + |> Enum.map(&User.get_cached_by_ap_id/1) + + res + |> Map.put( + emoji, + AccountView.render("accounts.json", %{users: users, for: user, as: :user}) + ) + end) + + conn + |> json(reactions) + else + _e -> + conn + |> json(%{}) + end + end + def react_with_emoji(%{assigns: %{user: user}} = conn, %{"id" => activity_id, "emoji" => emoji}) do with {:ok, _activity, _object} <- CommonAPI.react_with_emoji(activity_id, user, emoji), activity = Activity.get_by_id(activity_id) do diff --git a/lib/pleroma/web/router.ex b/lib/pleroma/web/router.ex index 6cca54211..ec6179420 100644 --- a/lib/pleroma/web/router.ex +++ b/lib/pleroma/web/router.ex @@ -265,6 +265,12 @@ defmodule Pleroma.Web.Router do end end + scope "/api/v1/pleroma", Pleroma.Web.PleromaAPI do + pipe_through(:api) + + get("/statuses/:id/emoji_reactions_by", PleromaAPIController, :emoji_reactions_by) + end + scope "/api/v1/pleroma", Pleroma.Web.PleromaAPI do pipe_through(:authenticated_api) diff --git a/test/web/pleroma_api/pleroma_api_controller_test.exs b/test/web/pleroma_api/pleroma_api_controller_test.exs index aab0c774e..71e4d3e1c 100644 --- a/test/web/pleroma_api/pleroma_api_controller_test.exs +++ b/test/web/pleroma_api/pleroma_api_controller_test.exs @@ -8,6 +8,7 @@ defmodule Pleroma.Web.PleromaAPI.PleromaAPIControllerTest do alias Pleroma.Conversation.Participation alias Pleroma.Repo alias Pleroma.Web.CommonAPI + alias Pleroma.Web.MastodonAPI.AccountView import Pleroma.Factory @@ -26,6 +27,30 @@ test "POST /api/v1/pleroma/statuses/:id/react_with_emoji", %{conn: conn} do assert to_string(activity.id) == id end + test "GET /api/v1/pleroma/statuses/:id/emoji_reactions_by", %{conn: conn} do + user = insert(:user) + other_user = insert(:user) + + {:ok, activity} = CommonAPI.post(user, %{"status" => "#cofe"}) + + result = + conn + |> get("/api/v1/pleroma/statuses/#{activity.id}/emoji_reactions_by") + |> json_response(200) + + assert result == %{} + + {:ok, _, _} = CommonAPI.react_with_emoji(activity.id, other_user, "🎅") + + result = + conn + |> get("/api/v1/pleroma/statuses/#{activity.id}/emoji_reactions_by") + |> json_response(200) + + [represented_user] = result["🎅"] + assert represented_user["id"] == other_user.id + end + test "/api/v1/pleroma/conversations/:id", %{conn: conn} do user = insert(:user) other_user = insert(:user) From 8d4b661ecb549ba554815ca55a29ec5872c68380 Mon Sep 17 00:00:00 2001 From: lain Date: Thu, 12 Sep 2019 18:59:13 +0200 Subject: [PATCH 007/154] Transmogrifier: Strip internal emoji reaction fields. --- lib/pleroma/web/activity_pub/transmogrifier.ex | 4 +++- test/web/activity_pub/transmogrifier_test.exs | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/pleroma/web/activity_pub/transmogrifier.ex b/lib/pleroma/web/activity_pub/transmogrifier.ex index 9132df8cb..0b9cc4499 100644 --- a/lib/pleroma/web/activity_pub/transmogrifier.ex +++ b/lib/pleroma/web/activity_pub/transmogrifier.ex @@ -995,9 +995,11 @@ def prepare_attachments(object) do |> Map.put("attachment", attachments) end - defp strip_internal_fields(object) do + def strip_internal_fields(object) do object |> Map.drop([ + "reactions", + "reaction_count", "likes", "like_count", "announcements", diff --git a/test/web/activity_pub/transmogrifier_test.exs b/test/web/activity_pub/transmogrifier_test.exs index 6df707370..20d274a02 100644 --- a/test/web/activity_pub/transmogrifier_test.exs +++ b/test/web/activity_pub/transmogrifier_test.exs @@ -491,6 +491,20 @@ test "it strips internal likes" do refute Map.has_key?(object.data, "likes") end + test "it strips internal reactions" do + user = insert(:user) + {:ok, activity} = CommonAPI.post(user, %{"status" => "#cofe"}) + {:ok, _, _} = CommonAPI.react_with_emoji(activity.id, user, "📢") + + %{object: object} = Activity.get_by_id_with_object(activity.id) + assert Map.has_key?(object.data, "reactions") + assert Map.has_key?(object.data, "reaction_count") + + object_data = Transmogrifier.strip_internal_fields(object.data) + refute Map.has_key?(object_data, "reactions") + refute Map.has_key?(object_data, "reaction_count") + end + test "it works for incoming update activities" do data = File.read!("test/fixtures/mastodon-post-activity.json") |> Poison.decode!() From a697f0d79148358da828d24ebfe12bbb9bb33b34 Mon Sep 17 00:00:00 2001 From: lain Date: Fri, 13 Sep 2019 02:11:02 +0200 Subject: [PATCH 008/154] Emoji: Add function to detect if a character is an emoji --- lib/pleroma/emoji-data.txt | 769 +++++++++++++++++++++++++++++++++++++ lib/pleroma/emoji.ex | 25 ++ test/emoji_test.exs | 8 + 3 files changed, 802 insertions(+) create mode 100644 lib/pleroma/emoji-data.txt diff --git a/lib/pleroma/emoji-data.txt b/lib/pleroma/emoji-data.txt new file mode 100644 index 000000000..2fb5c3ff6 --- /dev/null +++ b/lib/pleroma/emoji-data.txt @@ -0,0 +1,769 @@ +# emoji-data.txt +# Date: 2019-01-15, 12:10:05 GMT +# © 2019 Unicode®, Inc. +# Unicode and the Unicode Logo are registered trademarks of Unicode, Inc. in the U.S. and other countries. +# For terms of use, see http://www.unicode.org/terms_of_use.html +# +# Emoji Data for UTS #51 +# Version: 12.0 +# +# For documentation and usage, see http://www.unicode.org/reports/tr51 +# +# Format: +# ; # +# Note: there is no guarantee as to the structure of whitespace or comments +# +# Characters and sequences are listed in code point order. Users should be shown a more natural order. +# See the CLDR collation order for Emoji. + + +# ================================================ + +# All omitted code points have Emoji=No +# @missing: 0000..10FFFF ; Emoji ; No + +0023 ; Emoji # 1.1 [1] (#️) number sign +002A ; Emoji # 1.1 [1] (*️) asterisk +0030..0039 ; Emoji # 1.1 [10] (0️..9️) digit zero..digit nine +00A9 ; Emoji # 1.1 [1] (©️) copyright +00AE ; Emoji # 1.1 [1] (®️) registered +203C ; Emoji # 1.1 [1] (‼️) double exclamation mark +2049 ; Emoji # 3.0 [1] (⁉️) exclamation question mark +2122 ; Emoji # 1.1 [1] (™️) trade mark +2139 ; Emoji # 3.0 [1] (ℹ️) information +2194..2199 ; Emoji # 1.1 [6] (↔️..↙️) left-right arrow..down-left arrow +21A9..21AA ; Emoji # 1.1 [2] (↩️..↪️) right arrow curving left..left arrow curving right +231A..231B ; Emoji # 1.1 [2] (⌚..⌛) watch..hourglass done +2328 ; Emoji # 1.1 [1] (⌨️) keyboard +23CF ; Emoji # 4.0 [1] (⏏️) eject button +23E9..23F3 ; Emoji # 6.0 [11] (⏩..⏳) fast-forward button..hourglass not done +23F8..23FA ; Emoji # 7.0 [3] (⏸️..⏺️) pause button..record button +24C2 ; Emoji # 1.1 [1] (Ⓜ️) circled M +25AA..25AB ; Emoji # 1.1 [2] (▪️..▫️) black small square..white small square +25B6 ; Emoji # 1.1 [1] (▶️) play button +25C0 ; Emoji # 1.1 [1] (◀️) reverse button +25FB..25FE ; Emoji # 3.2 [4] (◻️..◾) white medium square..black medium-small square +2600..2604 ; Emoji # 1.1 [5] (☀️..☄️) sun..comet +260E ; Emoji # 1.1 [1] (☎️) telephone +2611 ; Emoji # 1.1 [1] (☑️) check box with check +2614..2615 ; Emoji # 4.0 [2] (☔..☕) umbrella with rain drops..hot beverage +2618 ; Emoji # 4.1 [1] (☘️) shamrock +261D ; Emoji # 1.1 [1] (☝️) index pointing up +2620 ; Emoji # 1.1 [1] (☠️) skull and crossbones +2622..2623 ; Emoji # 1.1 [2] (☢️..☣️) radioactive..biohazard +2626 ; Emoji # 1.1 [1] (☦️) orthodox cross +262A ; Emoji # 1.1 [1] (☪️) star and crescent +262E..262F ; Emoji # 1.1 [2] (☮️..☯️) peace symbol..yin yang +2638..263A ; Emoji # 1.1 [3] (☸️..☺️) wheel of dharma..smiling face +2640 ; Emoji # 1.1 [1] (♀️) female sign +2642 ; Emoji # 1.1 [1] (♂️) male sign +2648..2653 ; Emoji # 1.1 [12] (♈..♓) Aries..Pisces +265F..2660 ; Emoji # 1.1 [2] (♟️..♠️) chess pawn..spade suit +2663 ; Emoji # 1.1 [1] (♣️) club suit +2665..2666 ; Emoji # 1.1 [2] (♥️..♦️) heart suit..diamond suit +2668 ; Emoji # 1.1 [1] (♨️) hot springs +267B ; Emoji # 3.2 [1] (♻️) recycling symbol +267E..267F ; Emoji # 4.1 [2] (♾️..♿) infinity..wheelchair symbol +2692..2697 ; Emoji # 4.1 [6] (⚒️..⚗️) hammer and pick..alembic +2699 ; Emoji # 4.1 [1] (⚙️) gear +269B..269C ; Emoji # 4.1 [2] (⚛️..⚜️) atom symbol..fleur-de-lis +26A0..26A1 ; Emoji # 4.0 [2] (⚠️..⚡) warning..high voltage +26AA..26AB ; Emoji # 4.1 [2] (⚪..⚫) white circle..black circle +26B0..26B1 ; Emoji # 4.1 [2] (⚰️..⚱️) coffin..funeral urn +26BD..26BE ; Emoji # 5.2 [2] (⚽..⚾) soccer ball..baseball +26C4..26C5 ; Emoji # 5.2 [2] (⛄..⛅) snowman without snow..sun behind cloud +26C8 ; Emoji # 5.2 [1] (⛈️) cloud with lightning and rain +26CE ; Emoji # 6.0 [1] (⛎) Ophiuchus +26CF ; Emoji # 5.2 [1] (⛏️) pick +26D1 ; Emoji # 5.2 [1] (⛑️) rescue worker’s helmet +26D3..26D4 ; Emoji # 5.2 [2] (⛓️..⛔) chains..no entry +26E9..26EA ; Emoji # 5.2 [2] (⛩️..⛪) shinto shrine..church +26F0..26F5 ; Emoji # 5.2 [6] (⛰️..⛵) mountain..sailboat +26F7..26FA ; Emoji # 5.2 [4] (⛷️..⛺) skier..tent +26FD ; Emoji # 5.2 [1] (⛽) fuel pump +2702 ; Emoji # 1.1 [1] (✂️) scissors +2705 ; Emoji # 6.0 [1] (✅) check mark button +2708..2709 ; Emoji # 1.1 [2] (✈️..✉️) airplane..envelope +270A..270B ; Emoji # 6.0 [2] (✊..✋) raised fist..raised hand +270C..270D ; Emoji # 1.1 [2] (✌️..✍️) victory hand..writing hand +270F ; Emoji # 1.1 [1] (✏️) pencil +2712 ; Emoji # 1.1 [1] (✒️) black nib +2714 ; Emoji # 1.1 [1] (✔️) check mark +2716 ; Emoji # 1.1 [1] (✖️) multiplication sign +271D ; Emoji # 1.1 [1] (✝️) latin cross +2721 ; Emoji # 1.1 [1] (✡️) star of David +2728 ; Emoji # 6.0 [1] (✨) sparkles +2733..2734 ; Emoji # 1.1 [2] (✳️..✴️) eight-spoked asterisk..eight-pointed star +2744 ; Emoji # 1.1 [1] (❄️) snowflake +2747 ; Emoji # 1.1 [1] (❇️) sparkle +274C ; Emoji # 6.0 [1] (❌) cross mark +274E ; Emoji # 6.0 [1] (❎) cross mark button +2753..2755 ; Emoji # 6.0 [3] (❓..❕) question mark..white exclamation mark +2757 ; Emoji # 5.2 [1] (❗) exclamation mark +2763..2764 ; Emoji # 1.1 [2] (❣️..❤️) heart exclamation..red heart +2795..2797 ; Emoji # 6.0 [3] (➕..➗) plus sign..division sign +27A1 ; Emoji # 1.1 [1] (➡️) right arrow +27B0 ; Emoji # 6.0 [1] (➰) curly loop +27BF ; Emoji # 6.0 [1] (➿) double curly loop +2934..2935 ; Emoji # 3.2 [2] (⤴️..⤵️) right arrow curving up..right arrow curving down +2B05..2B07 ; Emoji # 4.0 [3] (⬅️..⬇️) left arrow..down arrow +2B1B..2B1C ; Emoji # 5.1 [2] (⬛..⬜) black large square..white large square +2B50 ; Emoji # 5.1 [1] (⭐) star +2B55 ; Emoji # 5.2 [1] (⭕) hollow red circle +3030 ; Emoji # 1.1 [1] (〰️) wavy dash +303D ; Emoji # 3.2 [1] (〽️) part alternation mark +3297 ; Emoji # 1.1 [1] (㊗️) Japanese “congratulations” button +3299 ; Emoji # 1.1 [1] (㊙️) Japanese “secret” button +1F004 ; Emoji # 5.1 [1] (🀄) mahjong red dragon +1F0CF ; Emoji # 6.0 [1] (🃏) joker +1F170..1F171 ; Emoji # 6.0 [2] (🅰️..🅱️) A button (blood type)..B button (blood type) +1F17E ; Emoji # 6.0 [1] (🅾️) O button (blood type) +1F17F ; Emoji # 5.2 [1] (🅿️) P button +1F18E ; Emoji # 6.0 [1] (🆎) AB button (blood type) +1F191..1F19A ; Emoji # 6.0 [10] (🆑..🆚) CL button..VS button +1F1E6..1F1FF ; Emoji # 6.0 [26] (🇦..🇿) regional indicator symbol letter a..regional indicator symbol letter z +1F201..1F202 ; Emoji # 6.0 [2] (🈁..🈂️) Japanese “here” button..Japanese “service charge” button +1F21A ; Emoji # 5.2 [1] (🈚) Japanese “free of charge” button +1F22F ; Emoji # 5.2 [1] (🈯) Japanese “reserved” button +1F232..1F23A ; Emoji # 6.0 [9] (🈲..🈺) Japanese “prohibited” button..Japanese “open for business” button +1F250..1F251 ; Emoji # 6.0 [2] (🉐..🉑) Japanese “bargain” button..Japanese “acceptable” button +1F300..1F320 ; Emoji # 6.0 [33] (🌀..🌠) cyclone..shooting star +1F321 ; Emoji # 7.0 [1] (🌡️) thermometer +1F324..1F32C ; Emoji # 7.0 [9] (🌤️..🌬️) sun behind small cloud..wind face +1F32D..1F32F ; Emoji # 8.0 [3] (🌭..🌯) hot dog..burrito +1F330..1F335 ; Emoji # 6.0 [6] (🌰..🌵) chestnut..cactus +1F336 ; Emoji # 7.0 [1] (🌶️) hot pepper +1F337..1F37C ; Emoji # 6.0 [70] (🌷..🍼) tulip..baby bottle +1F37D ; Emoji # 7.0 [1] (🍽️) fork and knife with plate +1F37E..1F37F ; Emoji # 8.0 [2] (🍾..🍿) bottle with popping cork..popcorn +1F380..1F393 ; Emoji # 6.0 [20] (🎀..🎓) ribbon..graduation cap +1F396..1F397 ; Emoji # 7.0 [2] (🎖️..🎗️) military medal..reminder ribbon +1F399..1F39B ; Emoji # 7.0 [3] (🎙️..🎛️) studio microphone..control knobs +1F39E..1F39F ; Emoji # 7.0 [2] (🎞️..🎟️) film frames..admission tickets +1F3A0..1F3C4 ; Emoji # 6.0 [37] (🎠..🏄) carousel horse..person surfing +1F3C5 ; Emoji # 7.0 [1] (🏅) sports medal +1F3C6..1F3CA ; Emoji # 6.0 [5] (🏆..🏊) trophy..person swimming +1F3CB..1F3CE ; Emoji # 7.0 [4] (🏋️..🏎️) person lifting weights..racing car +1F3CF..1F3D3 ; Emoji # 8.0 [5] (🏏..🏓) cricket game..ping pong +1F3D4..1F3DF ; Emoji # 7.0 [12] (🏔️..🏟️) snow-capped mountain..stadium +1F3E0..1F3F0 ; Emoji # 6.0 [17] (🏠..🏰) house..castle +1F3F3..1F3F5 ; Emoji # 7.0 [3] (🏳️..🏵️) white flag..rosette +1F3F7 ; Emoji # 7.0 [1] (🏷️) label +1F3F8..1F3FF ; Emoji # 8.0 [8] (🏸..🏿) badminton..dark skin tone +1F400..1F43E ; Emoji # 6.0 [63] (🐀..🐾) rat..paw prints +1F43F ; Emoji # 7.0 [1] (🐿️) chipmunk +1F440 ; Emoji # 6.0 [1] (👀) eyes +1F441 ; Emoji # 7.0 [1] (👁️) eye +1F442..1F4F7 ; Emoji # 6.0[182] (👂..📷) ear..camera +1F4F8 ; Emoji # 7.0 [1] (📸) camera with flash +1F4F9..1F4FC ; Emoji # 6.0 [4] (📹..📼) video camera..videocassette +1F4FD ; Emoji # 7.0 [1] (📽️) film projector +1F4FF ; Emoji # 8.0 [1] (📿) prayer beads +1F500..1F53D ; Emoji # 6.0 [62] (🔀..🔽) shuffle tracks button..downwards button +1F549..1F54A ; Emoji # 7.0 [2] (🕉️..🕊️) om..dove +1F54B..1F54E ; Emoji # 8.0 [4] (🕋..🕎) kaaba..menorah +1F550..1F567 ; Emoji # 6.0 [24] (🕐..🕧) one o’clock..twelve-thirty +1F56F..1F570 ; Emoji # 7.0 [2] (🕯️..🕰️) candle..mantelpiece clock +1F573..1F579 ; Emoji # 7.0 [7] (🕳️..🕹️) hole..joystick +1F57A ; Emoji # 9.0 [1] (🕺) man dancing +1F587 ; Emoji # 7.0 [1] (🖇️) linked paperclips +1F58A..1F58D ; Emoji # 7.0 [4] (🖊️..🖍️) pen..crayon +1F590 ; Emoji # 7.0 [1] (🖐️) hand with fingers splayed +1F595..1F596 ; Emoji # 7.0 [2] (🖕..🖖) middle finger..vulcan salute +1F5A4 ; Emoji # 9.0 [1] (🖤) black heart +1F5A5 ; Emoji # 7.0 [1] (🖥️) desktop computer +1F5A8 ; Emoji # 7.0 [1] (🖨️) printer +1F5B1..1F5B2 ; Emoji # 7.0 [2] (🖱️..🖲️) computer mouse..trackball +1F5BC ; Emoji # 7.0 [1] (🖼️) framed picture +1F5C2..1F5C4 ; Emoji # 7.0 [3] (🗂️..🗄️) card index dividers..file cabinet +1F5D1..1F5D3 ; Emoji # 7.0 [3] (🗑️..🗓️) wastebasket..spiral calendar +1F5DC..1F5DE ; Emoji # 7.0 [3] (🗜️..🗞️) clamp..rolled-up newspaper +1F5E1 ; Emoji # 7.0 [1] (🗡️) dagger +1F5E3 ; Emoji # 7.0 [1] (🗣️) speaking head +1F5E8 ; Emoji # 7.0 [1] (🗨️) left speech bubble +1F5EF ; Emoji # 7.0 [1] (🗯️) right anger bubble +1F5F3 ; Emoji # 7.0 [1] (🗳️) ballot box with ballot +1F5FA ; Emoji # 7.0 [1] (🗺️) world map +1F5FB..1F5FF ; Emoji # 6.0 [5] (🗻..🗿) mount fuji..moai +1F600 ; Emoji # 6.1 [1] (😀) grinning face +1F601..1F610 ; Emoji # 6.0 [16] (😁..😐) beaming face with smiling eyes..neutral face +1F611 ; Emoji # 6.1 [1] (😑) expressionless face +1F612..1F614 ; Emoji # 6.0 [3] (😒..😔) unamused face..pensive face +1F615 ; Emoji # 6.1 [1] (😕) confused face +1F616 ; Emoji # 6.0 [1] (😖) confounded face +1F617 ; Emoji # 6.1 [1] (😗) kissing face +1F618 ; Emoji # 6.0 [1] (😘) face blowing a kiss +1F619 ; Emoji # 6.1 [1] (😙) kissing face with smiling eyes +1F61A ; Emoji # 6.0 [1] (😚) kissing face with closed eyes +1F61B ; Emoji # 6.1 [1] (😛) face with tongue +1F61C..1F61E ; Emoji # 6.0 [3] (😜..😞) winking face with tongue..disappointed face +1F61F ; Emoji # 6.1 [1] (😟) worried face +1F620..1F625 ; Emoji # 6.0 [6] (😠..😥) angry face..sad but relieved face +1F626..1F627 ; Emoji # 6.1 [2] (😦..😧) frowning face with open mouth..anguished face +1F628..1F62B ; Emoji # 6.0 [4] (😨..😫) fearful face..tired face +1F62C ; Emoji # 6.1 [1] (😬) grimacing face +1F62D ; Emoji # 6.0 [1] (😭) loudly crying face +1F62E..1F62F ; Emoji # 6.1 [2] (😮..😯) face with open mouth..hushed face +1F630..1F633 ; Emoji # 6.0 [4] (😰..😳) anxious face with sweat..flushed face +1F634 ; Emoji # 6.1 [1] (😴) sleeping face +1F635..1F640 ; Emoji # 6.0 [12] (😵..🙀) dizzy face..weary cat +1F641..1F642 ; Emoji # 7.0 [2] (🙁..🙂) slightly frowning face..slightly smiling face +1F643..1F644 ; Emoji # 8.0 [2] (🙃..🙄) upside-down face..face with rolling eyes +1F645..1F64F ; Emoji # 6.0 [11] (🙅..🙏) person gesturing NO..folded hands +1F680..1F6C5 ; Emoji # 6.0 [70] (🚀..🛅) rocket..left luggage +1F6CB..1F6CF ; Emoji # 7.0 [5] (🛋️..🛏️) couch and lamp..bed +1F6D0 ; Emoji # 8.0 [1] (🛐) place of worship +1F6D1..1F6D2 ; Emoji # 9.0 [2] (🛑..🛒) stop sign..shopping cart +1F6D5 ; Emoji # 12.0 [1] (🛕) hindu temple +1F6E0..1F6E5 ; Emoji # 7.0 [6] (🛠️..🛥️) hammer and wrench..motor boat +1F6E9 ; Emoji # 7.0 [1] (🛩️) small airplane +1F6EB..1F6EC ; Emoji # 7.0 [2] (🛫..🛬) airplane departure..airplane arrival +1F6F0 ; Emoji # 7.0 [1] (🛰️) satellite +1F6F3 ; Emoji # 7.0 [1] (🛳️) passenger ship +1F6F4..1F6F6 ; Emoji # 9.0 [3] (🛴..🛶) kick scooter..canoe +1F6F7..1F6F8 ; Emoji # 10.0 [2] (🛷..🛸) sled..flying saucer +1F6F9 ; Emoji # 11.0 [1] (🛹) skateboard +1F6FA ; Emoji # 12.0 [1] (🛺) auto rickshaw +1F7E0..1F7EB ; Emoji # 12.0 [12] (🟠..🟫) orange circle..brown square +1F90D..1F90F ; Emoji # 12.0 [3] (🤍..🤏) white heart..pinching hand +1F910..1F918 ; Emoji # 8.0 [9] (🤐..🤘) zipper-mouth face..sign of the horns +1F919..1F91E ; Emoji # 9.0 [6] (🤙..🤞) call me hand..crossed fingers +1F91F ; Emoji # 10.0 [1] (🤟) love-you gesture +1F920..1F927 ; Emoji # 9.0 [8] (🤠..🤧) cowboy hat face..sneezing face +1F928..1F92F ; Emoji # 10.0 [8] (🤨..🤯) face with raised eyebrow..exploding head +1F930 ; Emoji # 9.0 [1] (🤰) pregnant woman +1F931..1F932 ; Emoji # 10.0 [2] (🤱..🤲) breast-feeding..palms up together +1F933..1F93A ; Emoji # 9.0 [8] (🤳..🤺) selfie..person fencing +1F93C..1F93E ; Emoji # 9.0 [3] (🤼..🤾) people wrestling..person playing handball +1F93F ; Emoji # 12.0 [1] (🤿) diving mask +1F940..1F945 ; Emoji # 9.0 [6] (🥀..🥅) wilted flower..goal net +1F947..1F94B ; Emoji # 9.0 [5] (🥇..🥋) 1st place medal..martial arts uniform +1F94C ; Emoji # 10.0 [1] (🥌) curling stone +1F94D..1F94F ; Emoji # 11.0 [3] (🥍..🥏) lacrosse..flying disc +1F950..1F95E ; Emoji # 9.0 [15] (🥐..🥞) croissant..pancakes +1F95F..1F96B ; Emoji # 10.0 [13] (🥟..🥫) dumpling..canned food +1F96C..1F970 ; Emoji # 11.0 [5] (🥬..🥰) leafy green..smiling face with hearts +1F971 ; Emoji # 12.0 [1] (🥱) yawning face +1F973..1F976 ; Emoji # 11.0 [4] (🥳..🥶) partying face..cold face +1F97A ; Emoji # 11.0 [1] (🥺) pleading face +1F97B ; Emoji # 12.0 [1] (🥻) sari +1F97C..1F97F ; Emoji # 11.0 [4] (🥼..🥿) lab coat..flat shoe +1F980..1F984 ; Emoji # 8.0 [5] (🦀..🦄) crab..unicorn +1F985..1F991 ; Emoji # 9.0 [13] (🦅..🦑) eagle..squid +1F992..1F997 ; Emoji # 10.0 [6] (🦒..🦗) giraffe..cricket +1F998..1F9A2 ; Emoji # 11.0 [11] (🦘..🦢) kangaroo..swan +1F9A5..1F9AA ; Emoji # 12.0 [6] (🦥..🦪) sloth..oyster +1F9AE..1F9AF ; Emoji # 12.0 [2] (🦮..🦯) guide dog..probing cane +1F9B0..1F9B9 ; Emoji # 11.0 [10] (🦰..🦹) red hair..supervillain +1F9BA..1F9BF ; Emoji # 12.0 [6] (🦺..🦿) safety vest..mechanical leg +1F9C0 ; Emoji # 8.0 [1] (🧀) cheese wedge +1F9C1..1F9C2 ; Emoji # 11.0 [2] (🧁..🧂) cupcake..salt +1F9C3..1F9CA ; Emoji # 12.0 [8] (🧃..🧊) beverage box..ice cube +1F9CD..1F9CF ; Emoji # 12.0 [3] (🧍..🧏) person standing..deaf person +1F9D0..1F9E6 ; Emoji # 10.0 [23] (🧐..🧦) face with monocle..socks +1F9E7..1F9FF ; Emoji # 11.0 [25] (🧧..🧿) red envelope..nazar amulet +1FA70..1FA73 ; Emoji # 12.0 [4] (🩰..🩳) ballet shoes..shorts +1FA78..1FA7A ; Emoji # 12.0 [3] (🩸..🩺) drop of blood..stethoscope +1FA80..1FA82 ; Emoji # 12.0 [3] (🪀..🪂) yo-yo..parachute +1FA90..1FA95 ; Emoji # 12.0 [6] (🪐..🪕) ringed planet..banjo + +# Total elements: 1311 + +# ================================================ + +# All omitted code points have Emoji_Presentation=No +# @missing: 0000..10FFFF ; Emoji_Presentation ; No + +231A..231B ; Emoji_Presentation # 1.1 [2] (⌚..⌛) watch..hourglass done +23E9..23EC ; Emoji_Presentation # 6.0 [4] (⏩..⏬) fast-forward button..fast down button +23F0 ; Emoji_Presentation # 6.0 [1] (⏰) alarm clock +23F3 ; Emoji_Presentation # 6.0 [1] (⏳) hourglass not done +25FD..25FE ; Emoji_Presentation # 3.2 [2] (◽..◾) white medium-small square..black medium-small square +2614..2615 ; Emoji_Presentation # 4.0 [2] (☔..☕) umbrella with rain drops..hot beverage +2648..2653 ; Emoji_Presentation # 1.1 [12] (♈..♓) Aries..Pisces +267F ; Emoji_Presentation # 4.1 [1] (♿) wheelchair symbol +2693 ; Emoji_Presentation # 4.1 [1] (⚓) anchor +26A1 ; Emoji_Presentation # 4.0 [1] (⚡) high voltage +26AA..26AB ; Emoji_Presentation # 4.1 [2] (⚪..⚫) white circle..black circle +26BD..26BE ; Emoji_Presentation # 5.2 [2] (⚽..⚾) soccer ball..baseball +26C4..26C5 ; Emoji_Presentation # 5.2 [2] (⛄..⛅) snowman without snow..sun behind cloud +26CE ; Emoji_Presentation # 6.0 [1] (⛎) Ophiuchus +26D4 ; Emoji_Presentation # 5.2 [1] (⛔) no entry +26EA ; Emoji_Presentation # 5.2 [1] (⛪) church +26F2..26F3 ; Emoji_Presentation # 5.2 [2] (⛲..⛳) fountain..flag in hole +26F5 ; Emoji_Presentation # 5.2 [1] (⛵) sailboat +26FA ; Emoji_Presentation # 5.2 [1] (⛺) tent +26FD ; Emoji_Presentation # 5.2 [1] (⛽) fuel pump +2705 ; Emoji_Presentation # 6.0 [1] (✅) check mark button +270A..270B ; Emoji_Presentation # 6.0 [2] (✊..✋) raised fist..raised hand +2728 ; Emoji_Presentation # 6.0 [1] (✨) sparkles +274C ; Emoji_Presentation # 6.0 [1] (❌) cross mark +274E ; Emoji_Presentation # 6.0 [1] (❎) cross mark button +2753..2755 ; Emoji_Presentation # 6.0 [3] (❓..❕) question mark..white exclamation mark +2757 ; Emoji_Presentation # 5.2 [1] (❗) exclamation mark +2795..2797 ; Emoji_Presentation # 6.0 [3] (➕..➗) plus sign..division sign +27B0 ; Emoji_Presentation # 6.0 [1] (➰) curly loop +27BF ; Emoji_Presentation # 6.0 [1] (➿) double curly loop +2B1B..2B1C ; Emoji_Presentation # 5.1 [2] (⬛..⬜) black large square..white large square +2B50 ; Emoji_Presentation # 5.1 [1] (⭐) star +2B55 ; Emoji_Presentation # 5.2 [1] (⭕) hollow red circle +1F004 ; Emoji_Presentation # 5.1 [1] (🀄) mahjong red dragon +1F0CF ; Emoji_Presentation # 6.0 [1] (🃏) joker +1F18E ; Emoji_Presentation # 6.0 [1] (🆎) AB button (blood type) +1F191..1F19A ; Emoji_Presentation # 6.0 [10] (🆑..🆚) CL button..VS button +1F1E6..1F1FF ; Emoji_Presentation # 6.0 [26] (🇦..🇿) regional indicator symbol letter a..regional indicator symbol letter z +1F201 ; Emoji_Presentation # 6.0 [1] (🈁) Japanese “here” button +1F21A ; Emoji_Presentation # 5.2 [1] (🈚) Japanese “free of charge” button +1F22F ; Emoji_Presentation # 5.2 [1] (🈯) Japanese “reserved” button +1F232..1F236 ; Emoji_Presentation # 6.0 [5] (🈲..🈶) Japanese “prohibited” button..Japanese “not free of charge” button +1F238..1F23A ; Emoji_Presentation # 6.0 [3] (🈸..🈺) Japanese “application” button..Japanese “open for business” button +1F250..1F251 ; Emoji_Presentation # 6.0 [2] (🉐..🉑) Japanese “bargain” button..Japanese “acceptable” button +1F300..1F320 ; Emoji_Presentation # 6.0 [33] (🌀..🌠) cyclone..shooting star +1F32D..1F32F ; Emoji_Presentation # 8.0 [3] (🌭..🌯) hot dog..burrito +1F330..1F335 ; Emoji_Presentation # 6.0 [6] (🌰..🌵) chestnut..cactus +1F337..1F37C ; Emoji_Presentation # 6.0 [70] (🌷..🍼) tulip..baby bottle +1F37E..1F37F ; Emoji_Presentation # 8.0 [2] (🍾..🍿) bottle with popping cork..popcorn +1F380..1F393 ; Emoji_Presentation # 6.0 [20] (🎀..🎓) ribbon..graduation cap +1F3A0..1F3C4 ; Emoji_Presentation # 6.0 [37] (🎠..🏄) carousel horse..person surfing +1F3C5 ; Emoji_Presentation # 7.0 [1] (🏅) sports medal +1F3C6..1F3CA ; Emoji_Presentation # 6.0 [5] (🏆..🏊) trophy..person swimming +1F3CF..1F3D3 ; Emoji_Presentation # 8.0 [5] (🏏..🏓) cricket game..ping pong +1F3E0..1F3F0 ; Emoji_Presentation # 6.0 [17] (🏠..🏰) house..castle +1F3F4 ; Emoji_Presentation # 7.0 [1] (🏴) black flag +1F3F8..1F3FF ; Emoji_Presentation # 8.0 [8] (🏸..🏿) badminton..dark skin tone +1F400..1F43E ; Emoji_Presentation # 6.0 [63] (🐀..🐾) rat..paw prints +1F440 ; Emoji_Presentation # 6.0 [1] (👀) eyes +1F442..1F4F7 ; Emoji_Presentation # 6.0[182] (👂..📷) ear..camera +1F4F8 ; Emoji_Presentation # 7.0 [1] (📸) camera with flash +1F4F9..1F4FC ; Emoji_Presentation # 6.0 [4] (📹..📼) video camera..videocassette +1F4FF ; Emoji_Presentation # 8.0 [1] (📿) prayer beads +1F500..1F53D ; Emoji_Presentation # 6.0 [62] (🔀..🔽) shuffle tracks button..downwards button +1F54B..1F54E ; Emoji_Presentation # 8.0 [4] (🕋..🕎) kaaba..menorah +1F550..1F567 ; Emoji_Presentation # 6.0 [24] (🕐..🕧) one o’clock..twelve-thirty +1F57A ; Emoji_Presentation # 9.0 [1] (🕺) man dancing +1F595..1F596 ; Emoji_Presentation # 7.0 [2] (🖕..🖖) middle finger..vulcan salute +1F5A4 ; Emoji_Presentation # 9.0 [1] (🖤) black heart +1F5FB..1F5FF ; Emoji_Presentation # 6.0 [5] (🗻..🗿) mount fuji..moai +1F600 ; Emoji_Presentation # 6.1 [1] (😀) grinning face +1F601..1F610 ; Emoji_Presentation # 6.0 [16] (😁..😐) beaming face with smiling eyes..neutral face +1F611 ; Emoji_Presentation # 6.1 [1] (😑) expressionless face +1F612..1F614 ; Emoji_Presentation # 6.0 [3] (😒..😔) unamused face..pensive face +1F615 ; Emoji_Presentation # 6.1 [1] (😕) confused face +1F616 ; Emoji_Presentation # 6.0 [1] (😖) confounded face +1F617 ; Emoji_Presentation # 6.1 [1] (😗) kissing face +1F618 ; Emoji_Presentation # 6.0 [1] (😘) face blowing a kiss +1F619 ; Emoji_Presentation # 6.1 [1] (😙) kissing face with smiling eyes +1F61A ; Emoji_Presentation # 6.0 [1] (😚) kissing face with closed eyes +1F61B ; Emoji_Presentation # 6.1 [1] (😛) face with tongue +1F61C..1F61E ; Emoji_Presentation # 6.0 [3] (😜..😞) winking face with tongue..disappointed face +1F61F ; Emoji_Presentation # 6.1 [1] (😟) worried face +1F620..1F625 ; Emoji_Presentation # 6.0 [6] (😠..😥) angry face..sad but relieved face +1F626..1F627 ; Emoji_Presentation # 6.1 [2] (😦..😧) frowning face with open mouth..anguished face +1F628..1F62B ; Emoji_Presentation # 6.0 [4] (😨..😫) fearful face..tired face +1F62C ; Emoji_Presentation # 6.1 [1] (😬) grimacing face +1F62D ; Emoji_Presentation # 6.0 [1] (😭) loudly crying face +1F62E..1F62F ; Emoji_Presentation # 6.1 [2] (😮..😯) face with open mouth..hushed face +1F630..1F633 ; Emoji_Presentation # 6.0 [4] (😰..😳) anxious face with sweat..flushed face +1F634 ; Emoji_Presentation # 6.1 [1] (😴) sleeping face +1F635..1F640 ; Emoji_Presentation # 6.0 [12] (😵..🙀) dizzy face..weary cat +1F641..1F642 ; Emoji_Presentation # 7.0 [2] (🙁..🙂) slightly frowning face..slightly smiling face +1F643..1F644 ; Emoji_Presentation # 8.0 [2] (🙃..🙄) upside-down face..face with rolling eyes +1F645..1F64F ; Emoji_Presentation # 6.0 [11] (🙅..🙏) person gesturing NO..folded hands +1F680..1F6C5 ; Emoji_Presentation # 6.0 [70] (🚀..🛅) rocket..left luggage +1F6CC ; Emoji_Presentation # 7.0 [1] (🛌) person in bed +1F6D0 ; Emoji_Presentation # 8.0 [1] (🛐) place of worship +1F6D1..1F6D2 ; Emoji_Presentation # 9.0 [2] (🛑..🛒) stop sign..shopping cart +1F6D5 ; Emoji_Presentation # 12.0 [1] (🛕) hindu temple +1F6EB..1F6EC ; Emoji_Presentation # 7.0 [2] (🛫..🛬) airplane departure..airplane arrival +1F6F4..1F6F6 ; Emoji_Presentation # 9.0 [3] (🛴..🛶) kick scooter..canoe +1F6F7..1F6F8 ; Emoji_Presentation # 10.0 [2] (🛷..🛸) sled..flying saucer +1F6F9 ; Emoji_Presentation # 11.0 [1] (🛹) skateboard +1F6FA ; Emoji_Presentation # 12.0 [1] (🛺) auto rickshaw +1F7E0..1F7EB ; Emoji_Presentation # 12.0 [12] (🟠..🟫) orange circle..brown square +1F90D..1F90F ; Emoji_Presentation # 12.0 [3] (🤍..🤏) white heart..pinching hand +1F910..1F918 ; Emoji_Presentation # 8.0 [9] (🤐..🤘) zipper-mouth face..sign of the horns +1F919..1F91E ; Emoji_Presentation # 9.0 [6] (🤙..🤞) call me hand..crossed fingers +1F91F ; Emoji_Presentation # 10.0 [1] (🤟) love-you gesture +1F920..1F927 ; Emoji_Presentation # 9.0 [8] (🤠..🤧) cowboy hat face..sneezing face +1F928..1F92F ; Emoji_Presentation # 10.0 [8] (🤨..🤯) face with raised eyebrow..exploding head +1F930 ; Emoji_Presentation # 9.0 [1] (🤰) pregnant woman +1F931..1F932 ; Emoji_Presentation # 10.0 [2] (🤱..🤲) breast-feeding..palms up together +1F933..1F93A ; Emoji_Presentation # 9.0 [8] (🤳..🤺) selfie..person fencing +1F93C..1F93E ; Emoji_Presentation # 9.0 [3] (🤼..🤾) people wrestling..person playing handball +1F93F ; Emoji_Presentation # 12.0 [1] (🤿) diving mask +1F940..1F945 ; Emoji_Presentation # 9.0 [6] (🥀..🥅) wilted flower..goal net +1F947..1F94B ; Emoji_Presentation # 9.0 [5] (🥇..🥋) 1st place medal..martial arts uniform +1F94C ; Emoji_Presentation # 10.0 [1] (🥌) curling stone +1F94D..1F94F ; Emoji_Presentation # 11.0 [3] (🥍..🥏) lacrosse..flying disc +1F950..1F95E ; Emoji_Presentation # 9.0 [15] (🥐..🥞) croissant..pancakes +1F95F..1F96B ; Emoji_Presentation # 10.0 [13] (🥟..🥫) dumpling..canned food +1F96C..1F970 ; Emoji_Presentation # 11.0 [5] (🥬..🥰) leafy green..smiling face with hearts +1F971 ; Emoji_Presentation # 12.0 [1] (🥱) yawning face +1F973..1F976 ; Emoji_Presentation # 11.0 [4] (🥳..🥶) partying face..cold face +1F97A ; Emoji_Presentation # 11.0 [1] (🥺) pleading face +1F97B ; Emoji_Presentation # 12.0 [1] (🥻) sari +1F97C..1F97F ; Emoji_Presentation # 11.0 [4] (🥼..🥿) lab coat..flat shoe +1F980..1F984 ; Emoji_Presentation # 8.0 [5] (🦀..🦄) crab..unicorn +1F985..1F991 ; Emoji_Presentation # 9.0 [13] (🦅..🦑) eagle..squid +1F992..1F997 ; Emoji_Presentation # 10.0 [6] (🦒..🦗) giraffe..cricket +1F998..1F9A2 ; Emoji_Presentation # 11.0 [11] (🦘..🦢) kangaroo..swan +1F9A5..1F9AA ; Emoji_Presentation # 12.0 [6] (🦥..🦪) sloth..oyster +1F9AE..1F9AF ; Emoji_Presentation # 12.0 [2] (🦮..🦯) guide dog..probing cane +1F9B0..1F9B9 ; Emoji_Presentation # 11.0 [10] (🦰..🦹) red hair..supervillain +1F9BA..1F9BF ; Emoji_Presentation # 12.0 [6] (🦺..🦿) safety vest..mechanical leg +1F9C0 ; Emoji_Presentation # 8.0 [1] (🧀) cheese wedge +1F9C1..1F9C2 ; Emoji_Presentation # 11.0 [2] (🧁..🧂) cupcake..salt +1F9C3..1F9CA ; Emoji_Presentation # 12.0 [8] (🧃..🧊) beverage box..ice cube +1F9CD..1F9CF ; Emoji_Presentation # 12.0 [3] (🧍..🧏) person standing..deaf person +1F9D0..1F9E6 ; Emoji_Presentation # 10.0 [23] (🧐..🧦) face with monocle..socks +1F9E7..1F9FF ; Emoji_Presentation # 11.0 [25] (🧧..🧿) red envelope..nazar amulet +1FA70..1FA73 ; Emoji_Presentation # 12.0 [4] (🩰..🩳) ballet shoes..shorts +1FA78..1FA7A ; Emoji_Presentation # 12.0 [3] (🩸..🩺) drop of blood..stethoscope +1FA80..1FA82 ; Emoji_Presentation # 12.0 [3] (🪀..🪂) yo-yo..parachute +1FA90..1FA95 ; Emoji_Presentation # 12.0 [6] (🪐..🪕) ringed planet..banjo + +# Total elements: 1093 + +# ================================================ + +# All omitted code points have Emoji_Modifier=No +# @missing: 0000..10FFFF ; Emoji_Modifier ; No + +1F3FB..1F3FF ; Emoji_Modifier # 8.0 [5] (🏻..🏿) light skin tone..dark skin tone + +# Total elements: 5 + +# ================================================ + +# All omitted code points have Emoji_Modifier_Base=No +# @missing: 0000..10FFFF ; Emoji_Modifier_Base ; No + +261D ; Emoji_Modifier_Base # 1.1 [1] (☝️) index pointing up +26F9 ; Emoji_Modifier_Base # 5.2 [1] (⛹️) person bouncing ball +270A..270B ; Emoji_Modifier_Base # 6.0 [2] (✊..✋) raised fist..raised hand +270C..270D ; Emoji_Modifier_Base # 1.1 [2] (✌️..✍️) victory hand..writing hand +1F385 ; Emoji_Modifier_Base # 6.0 [1] (🎅) Santa Claus +1F3C2..1F3C4 ; Emoji_Modifier_Base # 6.0 [3] (🏂..🏄) snowboarder..person surfing +1F3C7 ; Emoji_Modifier_Base # 6.0 [1] (🏇) horse racing +1F3CA ; Emoji_Modifier_Base # 6.0 [1] (🏊) person swimming +1F3CB..1F3CC ; Emoji_Modifier_Base # 7.0 [2] (🏋️..🏌️) person lifting weights..person golfing +1F442..1F443 ; Emoji_Modifier_Base # 6.0 [2] (👂..👃) ear..nose +1F446..1F450 ; Emoji_Modifier_Base # 6.0 [11] (👆..👐) backhand index pointing up..open hands +1F466..1F478 ; Emoji_Modifier_Base # 6.0 [19] (👦..👸) boy..princess +1F47C ; Emoji_Modifier_Base # 6.0 [1] (👼) baby angel +1F481..1F483 ; Emoji_Modifier_Base # 6.0 [3] (💁..💃) person tipping hand..woman dancing +1F485..1F487 ; Emoji_Modifier_Base # 6.0 [3] (💅..💇) nail polish..person getting haircut +1F48F ; Emoji_Modifier_Base # 6.0 [1] (💏) kiss +1F491 ; Emoji_Modifier_Base # 6.0 [1] (💑) couple with heart +1F4AA ; Emoji_Modifier_Base # 6.0 [1] (💪) flexed biceps +1F574..1F575 ; Emoji_Modifier_Base # 7.0 [2] (🕴️..🕵️) man in suit levitating..detective +1F57A ; Emoji_Modifier_Base # 9.0 [1] (🕺) man dancing +1F590 ; Emoji_Modifier_Base # 7.0 [1] (🖐️) hand with fingers splayed +1F595..1F596 ; Emoji_Modifier_Base # 7.0 [2] (🖕..🖖) middle finger..vulcan salute +1F645..1F647 ; Emoji_Modifier_Base # 6.0 [3] (🙅..🙇) person gesturing NO..person bowing +1F64B..1F64F ; Emoji_Modifier_Base # 6.0 [5] (🙋..🙏) person raising hand..folded hands +1F6A3 ; Emoji_Modifier_Base # 6.0 [1] (🚣) person rowing boat +1F6B4..1F6B6 ; Emoji_Modifier_Base # 6.0 [3] (🚴..🚶) person biking..person walking +1F6C0 ; Emoji_Modifier_Base # 6.0 [1] (🛀) person taking bath +1F6CC ; Emoji_Modifier_Base # 7.0 [1] (🛌) person in bed +1F90F ; Emoji_Modifier_Base # 12.0 [1] (🤏) pinching hand +1F918 ; Emoji_Modifier_Base # 8.0 [1] (🤘) sign of the horns +1F919..1F91E ; Emoji_Modifier_Base # 9.0 [6] (🤙..🤞) call me hand..crossed fingers +1F91F ; Emoji_Modifier_Base # 10.0 [1] (🤟) love-you gesture +1F926 ; Emoji_Modifier_Base # 9.0 [1] (🤦) person facepalming +1F930 ; Emoji_Modifier_Base # 9.0 [1] (🤰) pregnant woman +1F931..1F932 ; Emoji_Modifier_Base # 10.0 [2] (🤱..🤲) breast-feeding..palms up together +1F933..1F939 ; Emoji_Modifier_Base # 9.0 [7] (🤳..🤹) selfie..person juggling +1F93C..1F93E ; Emoji_Modifier_Base # 9.0 [3] (🤼..🤾) people wrestling..person playing handball +1F9B5..1F9B6 ; Emoji_Modifier_Base # 11.0 [2] (🦵..🦶) leg..foot +1F9B8..1F9B9 ; Emoji_Modifier_Base # 11.0 [2] (🦸..🦹) superhero..supervillain +1F9BB ; Emoji_Modifier_Base # 12.0 [1] (🦻) ear with hearing aid +1F9CD..1F9CF ; Emoji_Modifier_Base # 12.0 [3] (🧍..🧏) person standing..deaf person +1F9D1..1F9DD ; Emoji_Modifier_Base # 10.0 [13] (🧑..🧝) person..elf + +# Total elements: 120 + +# ================================================ + +# All omitted code points have Emoji_Component=No +# @missing: 0000..10FFFF ; Emoji_Component ; No + +0023 ; Emoji_Component # 1.1 [1] (#️) number sign +002A ; Emoji_Component # 1.1 [1] (*️) asterisk +0030..0039 ; Emoji_Component # 1.1 [10] (0️..9️) digit zero..digit nine +200D ; Emoji_Component # 1.1 [1] (‍) zero width joiner +20E3 ; Emoji_Component # 3.0 [1] (⃣) combining enclosing keycap +FE0F ; Emoji_Component # 3.2 [1] () VARIATION SELECTOR-16 +1F1E6..1F1FF ; Emoji_Component # 6.0 [26] (🇦..🇿) regional indicator symbol letter a..regional indicator symbol letter z +1F3FB..1F3FF ; Emoji_Component # 8.0 [5] (🏻..🏿) light skin tone..dark skin tone +1F9B0..1F9B3 ; Emoji_Component # 11.0 [4] (🦰..🦳) red hair..white hair +E0020..E007F ; Emoji_Component # 3.1 [96] (󠀠..󠁿) tag space..cancel tag + +# Total elements: 146 + +# ================================================ + +# All omitted code points have Extended_Pictographic=No +# @missing: 0000..10FFFF ; Extended_Pictographic ; No + +00A9 ; Extended_Pictographic# 1.1 [1] (©️) copyright +00AE ; Extended_Pictographic# 1.1 [1] (®️) registered +203C ; Extended_Pictographic# 1.1 [1] (‼️) double exclamation mark +2049 ; Extended_Pictographic# 3.0 [1] (⁉️) exclamation question mark +2122 ; Extended_Pictographic# 1.1 [1] (™️) trade mark +2139 ; Extended_Pictographic# 3.0 [1] (ℹ️) information +2194..2199 ; Extended_Pictographic# 1.1 [6] (↔️..↙️) left-right arrow..down-left arrow +21A9..21AA ; Extended_Pictographic# 1.1 [2] (↩️..↪️) right arrow curving left..left arrow curving right +231A..231B ; Extended_Pictographic# 1.1 [2] (⌚..⌛) watch..hourglass done +2328 ; Extended_Pictographic# 1.1 [1] (⌨️) keyboard +2388 ; Extended_Pictographic# 3.0 [1] (⎈) HELM SYMBOL +23CF ; Extended_Pictographic# 4.0 [1] (⏏️) eject button +23E9..23F3 ; Extended_Pictographic# 6.0 [11] (⏩..⏳) fast-forward button..hourglass not done +23F8..23FA ; Extended_Pictographic# 7.0 [3] (⏸️..⏺️) pause button..record button +24C2 ; Extended_Pictographic# 1.1 [1] (Ⓜ️) circled M +25AA..25AB ; Extended_Pictographic# 1.1 [2] (▪️..▫️) black small square..white small square +25B6 ; Extended_Pictographic# 1.1 [1] (▶️) play button +25C0 ; Extended_Pictographic# 1.1 [1] (◀️) reverse button +25FB..25FE ; Extended_Pictographic# 3.2 [4] (◻️..◾) white medium square..black medium-small square +2600..2605 ; Extended_Pictographic# 1.1 [6] (☀️..★) sun..BLACK STAR +2607..2612 ; Extended_Pictographic# 1.1 [12] (☇..☒) LIGHTNING..BALLOT BOX WITH X +2614..2615 ; Extended_Pictographic# 4.0 [2] (☔..☕) umbrella with rain drops..hot beverage +2616..2617 ; Extended_Pictographic# 3.2 [2] (☖..☗) WHITE SHOGI PIECE..BLACK SHOGI PIECE +2618 ; Extended_Pictographic# 4.1 [1] (☘️) shamrock +2619 ; Extended_Pictographic# 3.0 [1] (☙) REVERSED ROTATED FLORAL HEART BULLET +261A..266F ; Extended_Pictographic# 1.1 [86] (☚..♯) BLACK LEFT POINTING INDEX..MUSIC SHARP SIGN +2670..2671 ; Extended_Pictographic# 3.0 [2] (♰..♱) WEST SYRIAC CROSS..EAST SYRIAC CROSS +2672..267D ; Extended_Pictographic# 3.2 [12] (♲..♽) UNIVERSAL RECYCLING SYMBOL..PARTIALLY-RECYCLED PAPER SYMBOL +267E..267F ; Extended_Pictographic# 4.1 [2] (♾️..♿) infinity..wheelchair symbol +2680..2685 ; Extended_Pictographic# 3.2 [6] (⚀..⚅) DIE FACE-1..DIE FACE-6 +2690..2691 ; Extended_Pictographic# 4.0 [2] (⚐..⚑) WHITE FLAG..BLACK FLAG +2692..269C ; Extended_Pictographic# 4.1 [11] (⚒️..⚜️) hammer and pick..fleur-de-lis +269D ; Extended_Pictographic# 5.1 [1] (⚝) OUTLINED WHITE STAR +269E..269F ; Extended_Pictographic# 5.2 [2] (⚞..⚟) THREE LINES CONVERGING RIGHT..THREE LINES CONVERGING LEFT +26A0..26A1 ; Extended_Pictographic# 4.0 [2] (⚠️..⚡) warning..high voltage +26A2..26B1 ; Extended_Pictographic# 4.1 [16] (⚢..⚱️) DOUBLED FEMALE SIGN..funeral urn +26B2 ; Extended_Pictographic# 5.0 [1] (⚲) NEUTER +26B3..26BC ; Extended_Pictographic# 5.1 [10] (⚳..⚼) CERES..SESQUIQUADRATE +26BD..26BF ; Extended_Pictographic# 5.2 [3] (⚽..⚿) soccer ball..SQUARED KEY +26C0..26C3 ; Extended_Pictographic# 5.1 [4] (⛀..⛃) WHITE DRAUGHTS MAN..BLACK DRAUGHTS KING +26C4..26CD ; Extended_Pictographic# 5.2 [10] (⛄..⛍) snowman without snow..DISABLED CAR +26CE ; Extended_Pictographic# 6.0 [1] (⛎) Ophiuchus +26CF..26E1 ; Extended_Pictographic# 5.2 [19] (⛏️..⛡) pick..RESTRICTED LEFT ENTRY-2 +26E2 ; Extended_Pictographic# 6.0 [1] (⛢) ASTRONOMICAL SYMBOL FOR URANUS +26E3 ; Extended_Pictographic# 5.2 [1] (⛣) HEAVY CIRCLE WITH STROKE AND TWO DOTS ABOVE +26E4..26E7 ; Extended_Pictographic# 6.0 [4] (⛤..⛧) PENTAGRAM..INVERTED PENTAGRAM +26E8..26FF ; Extended_Pictographic# 5.2 [24] (⛨..⛿) BLACK CROSS ON SHIELD..WHITE FLAG WITH HORIZONTAL MIDDLE BLACK STRIPE +2700 ; Extended_Pictographic# 7.0 [1] (✀) BLACK SAFETY SCISSORS +2701..2704 ; Extended_Pictographic# 1.1 [4] (✁..✄) UPPER BLADE SCISSORS..WHITE SCISSORS +2705 ; Extended_Pictographic# 6.0 [1] (✅) check mark button +2708..2709 ; Extended_Pictographic# 1.1 [2] (✈️..✉️) airplane..envelope +270A..270B ; Extended_Pictographic# 6.0 [2] (✊..✋) raised fist..raised hand +270C..2712 ; Extended_Pictographic# 1.1 [7] (✌️..✒️) victory hand..black nib +2714 ; Extended_Pictographic# 1.1 [1] (✔️) check mark +2716 ; Extended_Pictographic# 1.1 [1] (✖️) multiplication sign +271D ; Extended_Pictographic# 1.1 [1] (✝️) latin cross +2721 ; Extended_Pictographic# 1.1 [1] (✡️) star of David +2728 ; Extended_Pictographic# 6.0 [1] (✨) sparkles +2733..2734 ; Extended_Pictographic# 1.1 [2] (✳️..✴️) eight-spoked asterisk..eight-pointed star +2744 ; Extended_Pictographic# 1.1 [1] (❄️) snowflake +2747 ; Extended_Pictographic# 1.1 [1] (❇️) sparkle +274C ; Extended_Pictographic# 6.0 [1] (❌) cross mark +274E ; Extended_Pictographic# 6.0 [1] (❎) cross mark button +2753..2755 ; Extended_Pictographic# 6.0 [3] (❓..❕) question mark..white exclamation mark +2757 ; Extended_Pictographic# 5.2 [1] (❗) exclamation mark +2763..2767 ; Extended_Pictographic# 1.1 [5] (❣️..❧) heart exclamation..ROTATED FLORAL HEART BULLET +2795..2797 ; Extended_Pictographic# 6.0 [3] (➕..➗) plus sign..division sign +27A1 ; Extended_Pictographic# 1.1 [1] (➡️) right arrow +27B0 ; Extended_Pictographic# 6.0 [1] (➰) curly loop +27BF ; Extended_Pictographic# 6.0 [1] (➿) double curly loop +2934..2935 ; Extended_Pictographic# 3.2 [2] (⤴️..⤵️) right arrow curving up..right arrow curving down +2B05..2B07 ; Extended_Pictographic# 4.0 [3] (⬅️..⬇️) left arrow..down arrow +2B1B..2B1C ; Extended_Pictographic# 5.1 [2] (⬛..⬜) black large square..white large square +2B50 ; Extended_Pictographic# 5.1 [1] (⭐) star +2B55 ; Extended_Pictographic# 5.2 [1] (⭕) hollow red circle +3030 ; Extended_Pictographic# 1.1 [1] (〰️) wavy dash +303D ; Extended_Pictographic# 3.2 [1] (〽️) part alternation mark +3297 ; Extended_Pictographic# 1.1 [1] (㊗️) Japanese “congratulations” button +3299 ; Extended_Pictographic# 1.1 [1] (㊙️) Japanese “secret” button +1F000..1F02B ; Extended_Pictographic# 5.1 [44] (🀀..🀫) MAHJONG TILE EAST WIND..MAHJONG TILE BACK +1F02C..1F02F ; Extended_Pictographic# NA [4] (🀬..🀯) .. +1F030..1F093 ; Extended_Pictographic# 5.1[100] (🀰..🂓) DOMINO TILE HORIZONTAL BACK..DOMINO TILE VERTICAL-06-06 +1F094..1F09F ; Extended_Pictographic# NA [12] (🂔..🂟) .. +1F0A0..1F0AE ; Extended_Pictographic# 6.0 [15] (🂠..🂮) PLAYING CARD BACK..PLAYING CARD KING OF SPADES +1F0AF..1F0B0 ; Extended_Pictographic# NA [2] (🂯..🂰) .. +1F0B1..1F0BE ; Extended_Pictographic# 6.0 [14] (🂱..🂾) PLAYING CARD ACE OF HEARTS..PLAYING CARD KING OF HEARTS +1F0BF ; Extended_Pictographic# 7.0 [1] (🂿) PLAYING CARD RED JOKER +1F0C0 ; Extended_Pictographic# NA [1] (🃀) +1F0C1..1F0CF ; Extended_Pictographic# 6.0 [15] (🃁..🃏) PLAYING CARD ACE OF DIAMONDS..joker +1F0D0 ; Extended_Pictographic# NA [1] (🃐) +1F0D1..1F0DF ; Extended_Pictographic# 6.0 [15] (🃑..🃟) PLAYING CARD ACE OF CLUBS..PLAYING CARD WHITE JOKER +1F0E0..1F0F5 ; Extended_Pictographic# 7.0 [22] (🃠..🃵) PLAYING CARD FOOL..PLAYING CARD TRUMP-21 +1F0F6..1F0FF ; Extended_Pictographic# NA [10] (🃶..🃿) .. +1F10D..1F10F ; Extended_Pictographic# NA [3] (🄍..🄏) .. +1F12F ; Extended_Pictographic# 11.0 [1] (🄯) COPYLEFT SYMBOL +1F16C ; Extended_Pictographic# 12.0 [1] (🅬) RAISED MR SIGN +1F16D..1F16F ; Extended_Pictographic# NA [3] (🅭..🅯) .. +1F170..1F171 ; Extended_Pictographic# 6.0 [2] (🅰️..🅱️) A button (blood type)..B button (blood type) +1F17E ; Extended_Pictographic# 6.0 [1] (🅾️) O button (blood type) +1F17F ; Extended_Pictographic# 5.2 [1] (🅿️) P button +1F18E ; Extended_Pictographic# 6.0 [1] (🆎) AB button (blood type) +1F191..1F19A ; Extended_Pictographic# 6.0 [10] (🆑..🆚) CL button..VS button +1F1AD..1F1E5 ; Extended_Pictographic# NA [57] (🆭..🇥) .. +1F201..1F202 ; Extended_Pictographic# 6.0 [2] (🈁..🈂️) Japanese “here” button..Japanese “service charge” button +1F203..1F20F ; Extended_Pictographic# NA [13] (🈃..🈏) .. +1F21A ; Extended_Pictographic# 5.2 [1] (🈚) Japanese “free of charge” button +1F22F ; Extended_Pictographic# 5.2 [1] (🈯) Japanese “reserved” button +1F232..1F23A ; Extended_Pictographic# 6.0 [9] (🈲..🈺) Japanese “prohibited” button..Japanese “open for business” button +1F23C..1F23F ; Extended_Pictographic# NA [4] (🈼..🈿) .. +1F249..1F24F ; Extended_Pictographic# NA [7] (🉉..🉏) .. +1F250..1F251 ; Extended_Pictographic# 6.0 [2] (🉐..🉑) Japanese “bargain” button..Japanese “acceptable” button +1F252..1F25F ; Extended_Pictographic# NA [14] (🉒..🉟) .. +1F260..1F265 ; Extended_Pictographic# 10.0 [6] (🉠..🉥) ROUNDED SYMBOL FOR FU..ROUNDED SYMBOL FOR CAI +1F266..1F2FF ; Extended_Pictographic# NA[154] (🉦..🋿) .. +1F300..1F320 ; Extended_Pictographic# 6.0 [33] (🌀..🌠) cyclone..shooting star +1F321..1F32C ; Extended_Pictographic# 7.0 [12] (🌡️..🌬️) thermometer..wind face +1F32D..1F32F ; Extended_Pictographic# 8.0 [3] (🌭..🌯) hot dog..burrito +1F330..1F335 ; Extended_Pictographic# 6.0 [6] (🌰..🌵) chestnut..cactus +1F336 ; Extended_Pictographic# 7.0 [1] (🌶️) hot pepper +1F337..1F37C ; Extended_Pictographic# 6.0 [70] (🌷..🍼) tulip..baby bottle +1F37D ; Extended_Pictographic# 7.0 [1] (🍽️) fork and knife with plate +1F37E..1F37F ; Extended_Pictographic# 8.0 [2] (🍾..🍿) bottle with popping cork..popcorn +1F380..1F393 ; Extended_Pictographic# 6.0 [20] (🎀..🎓) ribbon..graduation cap +1F394..1F39F ; Extended_Pictographic# 7.0 [12] (🎔..🎟️) HEART WITH TIP ON THE LEFT..admission tickets +1F3A0..1F3C4 ; Extended_Pictographic# 6.0 [37] (🎠..🏄) carousel horse..person surfing +1F3C5 ; Extended_Pictographic# 7.0 [1] (🏅) sports medal +1F3C6..1F3CA ; Extended_Pictographic# 6.0 [5] (🏆..🏊) trophy..person swimming +1F3CB..1F3CE ; Extended_Pictographic# 7.0 [4] (🏋️..🏎️) person lifting weights..racing car +1F3CF..1F3D3 ; Extended_Pictographic# 8.0 [5] (🏏..🏓) cricket game..ping pong +1F3D4..1F3DF ; Extended_Pictographic# 7.0 [12] (🏔️..🏟️) snow-capped mountain..stadium +1F3E0..1F3F0 ; Extended_Pictographic# 6.0 [17] (🏠..🏰) house..castle +1F3F1..1F3F7 ; Extended_Pictographic# 7.0 [7] (🏱..🏷️) WHITE PENNANT..label +1F3F8..1F3FA ; Extended_Pictographic# 8.0 [3] (🏸..🏺) badminton..amphora +1F400..1F43E ; Extended_Pictographic# 6.0 [63] (🐀..🐾) rat..paw prints +1F43F ; Extended_Pictographic# 7.0 [1] (🐿️) chipmunk +1F440 ; Extended_Pictographic# 6.0 [1] (👀) eyes +1F441 ; Extended_Pictographic# 7.0 [1] (👁️) eye +1F442..1F4F7 ; Extended_Pictographic# 6.0[182] (👂..📷) ear..camera +1F4F8 ; Extended_Pictographic# 7.0 [1] (📸) camera with flash +1F4F9..1F4FC ; Extended_Pictographic# 6.0 [4] (📹..📼) video camera..videocassette +1F4FD..1F4FE ; Extended_Pictographic# 7.0 [2] (📽️..📾) film projector..PORTABLE STEREO +1F4FF ; Extended_Pictographic# 8.0 [1] (📿) prayer beads +1F500..1F53D ; Extended_Pictographic# 6.0 [62] (🔀..🔽) shuffle tracks button..downwards button +1F546..1F54A ; Extended_Pictographic# 7.0 [5] (🕆..🕊️) WHITE LATIN CROSS..dove +1F54B..1F54F ; Extended_Pictographic# 8.0 [5] (🕋..🕏) kaaba..BOWL OF HYGIEIA +1F550..1F567 ; Extended_Pictographic# 6.0 [24] (🕐..🕧) one o’clock..twelve-thirty +1F568..1F579 ; Extended_Pictographic# 7.0 [18] (🕨..🕹️) RIGHT SPEAKER..joystick +1F57A ; Extended_Pictographic# 9.0 [1] (🕺) man dancing +1F57B..1F5A3 ; Extended_Pictographic# 7.0 [41] (🕻..🖣) LEFT HAND TELEPHONE RECEIVER..BLACK DOWN POINTING BACKHAND INDEX +1F5A4 ; Extended_Pictographic# 9.0 [1] (🖤) black heart +1F5A5..1F5FA ; Extended_Pictographic# 7.0 [86] (🖥️..🗺️) desktop computer..world map +1F5FB..1F5FF ; Extended_Pictographic# 6.0 [5] (🗻..🗿) mount fuji..moai +1F600 ; Extended_Pictographic# 6.1 [1] (😀) grinning face +1F601..1F610 ; Extended_Pictographic# 6.0 [16] (😁..😐) beaming face with smiling eyes..neutral face +1F611 ; Extended_Pictographic# 6.1 [1] (😑) expressionless face +1F612..1F614 ; Extended_Pictographic# 6.0 [3] (😒..😔) unamused face..pensive face +1F615 ; Extended_Pictographic# 6.1 [1] (😕) confused face +1F616 ; Extended_Pictographic# 6.0 [1] (😖) confounded face +1F617 ; Extended_Pictographic# 6.1 [1] (😗) kissing face +1F618 ; Extended_Pictographic# 6.0 [1] (😘) face blowing a kiss +1F619 ; Extended_Pictographic# 6.1 [1] (😙) kissing face with smiling eyes +1F61A ; Extended_Pictographic# 6.0 [1] (😚) kissing face with closed eyes +1F61B ; Extended_Pictographic# 6.1 [1] (😛) face with tongue +1F61C..1F61E ; Extended_Pictographic# 6.0 [3] (😜..😞) winking face with tongue..disappointed face +1F61F ; Extended_Pictographic# 6.1 [1] (😟) worried face +1F620..1F625 ; Extended_Pictographic# 6.0 [6] (😠..😥) angry face..sad but relieved face +1F626..1F627 ; Extended_Pictographic# 6.1 [2] (😦..😧) frowning face with open mouth..anguished face +1F628..1F62B ; Extended_Pictographic# 6.0 [4] (😨..😫) fearful face..tired face +1F62C ; Extended_Pictographic# 6.1 [1] (😬) grimacing face +1F62D ; Extended_Pictographic# 6.0 [1] (😭) loudly crying face +1F62E..1F62F ; Extended_Pictographic# 6.1 [2] (😮..😯) face with open mouth..hushed face +1F630..1F633 ; Extended_Pictographic# 6.0 [4] (😰..😳) anxious face with sweat..flushed face +1F634 ; Extended_Pictographic# 6.1 [1] (😴) sleeping face +1F635..1F640 ; Extended_Pictographic# 6.0 [12] (😵..🙀) dizzy face..weary cat +1F641..1F642 ; Extended_Pictographic# 7.0 [2] (🙁..🙂) slightly frowning face..slightly smiling face +1F643..1F644 ; Extended_Pictographic# 8.0 [2] (🙃..🙄) upside-down face..face with rolling eyes +1F645..1F64F ; Extended_Pictographic# 6.0 [11] (🙅..🙏) person gesturing NO..folded hands +1F680..1F6C5 ; Extended_Pictographic# 6.0 [70] (🚀..🛅) rocket..left luggage +1F6C6..1F6CF ; Extended_Pictographic# 7.0 [10] (🛆..🛏️) TRIANGLE WITH ROUNDED CORNERS..bed +1F6D0 ; Extended_Pictographic# 8.0 [1] (🛐) place of worship +1F6D1..1F6D2 ; Extended_Pictographic# 9.0 [2] (🛑..🛒) stop sign..shopping cart +1F6D3..1F6D4 ; Extended_Pictographic# 10.0 [2] (🛓..🛔) STUPA..PAGODA +1F6D5 ; Extended_Pictographic# 12.0 [1] (🛕) hindu temple +1F6D6..1F6DF ; Extended_Pictographic# NA [10] (🛖..🛟) .. +1F6E0..1F6EC ; Extended_Pictographic# 7.0 [13] (🛠️..🛬) hammer and wrench..airplane arrival +1F6ED..1F6EF ; Extended_Pictographic# NA [3] (🛭..🛯) .. +1F6F0..1F6F3 ; Extended_Pictographic# 7.0 [4] (🛰️..🛳️) satellite..passenger ship +1F6F4..1F6F6 ; Extended_Pictographic# 9.0 [3] (🛴..🛶) kick scooter..canoe +1F6F7..1F6F8 ; Extended_Pictographic# 10.0 [2] (🛷..🛸) sled..flying saucer +1F6F9 ; Extended_Pictographic# 11.0 [1] (🛹) skateboard +1F6FA ; Extended_Pictographic# 12.0 [1] (🛺) auto rickshaw +1F6FB..1F6FF ; Extended_Pictographic# NA [5] (🛻..🛿) .. +1F774..1F77F ; Extended_Pictographic# NA [12] (🝴..🝿) .. +1F7D5..1F7D8 ; Extended_Pictographic# 11.0 [4] (🟕..🟘) CIRCLED TRIANGLE..NEGATIVE CIRCLED SQUARE +1F7D9..1F7DF ; Extended_Pictographic# NA [7] (🟙..🟟) .. +1F7E0..1F7EB ; Extended_Pictographic# 12.0 [12] (🟠..🟫) orange circle..brown square +1F7EC..1F7FF ; Extended_Pictographic# NA [20] (🟬..🟿) .. +1F80C..1F80F ; Extended_Pictographic# NA [4] (🠌..🠏) .. +1F848..1F84F ; Extended_Pictographic# NA [8] (🡈..🡏) .. +1F85A..1F85F ; Extended_Pictographic# NA [6] (🡚..🡟) .. +1F888..1F88F ; Extended_Pictographic# NA [8] (🢈..🢏) .. +1F8AE..1F8FF ; Extended_Pictographic# NA [82] (🢮..🣿) .. +1F90C ; Extended_Pictographic# NA [1] (🤌) +1F90D..1F90F ; Extended_Pictographic# 12.0 [3] (🤍..🤏) white heart..pinching hand +1F910..1F918 ; Extended_Pictographic# 8.0 [9] (🤐..🤘) zipper-mouth face..sign of the horns +1F919..1F91E ; Extended_Pictographic# 9.0 [6] (🤙..🤞) call me hand..crossed fingers +1F91F ; Extended_Pictographic# 10.0 [1] (🤟) love-you gesture +1F920..1F927 ; Extended_Pictographic# 9.0 [8] (🤠..🤧) cowboy hat face..sneezing face +1F928..1F92F ; Extended_Pictographic# 10.0 [8] (🤨..🤯) face with raised eyebrow..exploding head +1F930 ; Extended_Pictographic# 9.0 [1] (🤰) pregnant woman +1F931..1F932 ; Extended_Pictographic# 10.0 [2] (🤱..🤲) breast-feeding..palms up together +1F933..1F93A ; Extended_Pictographic# 9.0 [8] (🤳..🤺) selfie..person fencing +1F93C..1F93E ; Extended_Pictographic# 9.0 [3] (🤼..🤾) people wrestling..person playing handball +1F93F ; Extended_Pictographic# 12.0 [1] (🤿) diving mask +1F940..1F945 ; Extended_Pictographic# 9.0 [6] (🥀..🥅) wilted flower..goal net +1F947..1F94B ; Extended_Pictographic# 9.0 [5] (🥇..🥋) 1st place medal..martial arts uniform +1F94C ; Extended_Pictographic# 10.0 [1] (🥌) curling stone +1F94D..1F94F ; Extended_Pictographic# 11.0 [3] (🥍..🥏) lacrosse..flying disc +1F950..1F95E ; Extended_Pictographic# 9.0 [15] (🥐..🥞) croissant..pancakes +1F95F..1F96B ; Extended_Pictographic# 10.0 [13] (🥟..🥫) dumpling..canned food +1F96C..1F970 ; Extended_Pictographic# 11.0 [5] (🥬..🥰) leafy green..smiling face with hearts +1F971 ; Extended_Pictographic# 12.0 [1] (🥱) yawning face +1F972 ; Extended_Pictographic# NA [1] (🥲) +1F973..1F976 ; Extended_Pictographic# 11.0 [4] (🥳..🥶) partying face..cold face +1F977..1F979 ; Extended_Pictographic# NA [3] (🥷..🥹) .. +1F97A ; Extended_Pictographic# 11.0 [1] (🥺) pleading face +1F97B ; Extended_Pictographic# 12.0 [1] (🥻) sari +1F97C..1F97F ; Extended_Pictographic# 11.0 [4] (🥼..🥿) lab coat..flat shoe +1F980..1F984 ; Extended_Pictographic# 8.0 [5] (🦀..🦄) crab..unicorn +1F985..1F991 ; Extended_Pictographic# 9.0 [13] (🦅..🦑) eagle..squid +1F992..1F997 ; Extended_Pictographic# 10.0 [6] (🦒..🦗) giraffe..cricket +1F998..1F9A2 ; Extended_Pictographic# 11.0 [11] (🦘..🦢) kangaroo..swan +1F9A3..1F9A4 ; Extended_Pictographic# NA [2] (🦣..🦤) .. +1F9A5..1F9AA ; Extended_Pictographic# 12.0 [6] (🦥..🦪) sloth..oyster +1F9AB..1F9AD ; Extended_Pictographic# NA [3] (🦫..🦭) .. +1F9AE..1F9AF ; Extended_Pictographic# 12.0 [2] (🦮..🦯) guide dog..probing cane +1F9B0..1F9B9 ; Extended_Pictographic# 11.0 [10] (🦰..🦹) red hair..supervillain +1F9BA..1F9BF ; Extended_Pictographic# 12.0 [6] (🦺..🦿) safety vest..mechanical leg +1F9C0 ; Extended_Pictographic# 8.0 [1] (🧀) cheese wedge +1F9C1..1F9C2 ; Extended_Pictographic# 11.0 [2] (🧁..🧂) cupcake..salt +1F9C3..1F9CA ; Extended_Pictographic# 12.0 [8] (🧃..🧊) beverage box..ice cube +1F9CB..1F9CC ; Extended_Pictographic# NA [2] (🧋..🧌) .. +1F9CD..1F9CF ; Extended_Pictographic# 12.0 [3] (🧍..🧏) person standing..deaf person +1F9D0..1F9E6 ; Extended_Pictographic# 10.0 [23] (🧐..🧦) face with monocle..socks +1F9E7..1F9FF ; Extended_Pictographic# 11.0 [25] (🧧..🧿) red envelope..nazar amulet +1FA00..1FA53 ; Extended_Pictographic# 12.0 [84] (🨀..🩓) NEUTRAL CHESS KING..BLACK CHESS KNIGHT-BISHOP +1FA54..1FA5F ; Extended_Pictographic# NA [12] (🩔..🩟) .. +1FA60..1FA6D ; Extended_Pictographic# 11.0 [14] (🩠..🩭) XIANGQI RED GENERAL..XIANGQI BLACK SOLDIER +1FA6E..1FA6F ; Extended_Pictographic# NA [2] (🩮..🩯) .. +1FA70..1FA73 ; Extended_Pictographic# 12.0 [4] (🩰..🩳) ballet shoes..shorts +1FA74..1FA77 ; Extended_Pictographic# NA [4] (🩴..🩷) .. +1FA78..1FA7A ; Extended_Pictographic# 12.0 [3] (🩸..🩺) drop of blood..stethoscope +1FA7B..1FA7F ; Extended_Pictographic# NA [5] (🩻..🩿) .. +1FA80..1FA82 ; Extended_Pictographic# 12.0 [3] (🪀..🪂) yo-yo..parachute +1FA83..1FA8F ; Extended_Pictographic# NA [13] (🪃..🪏) .. +1FA90..1FA95 ; Extended_Pictographic# 12.0 [6] (🪐..🪕) ringed planet..banjo +1FA96..1FFFD ; Extended_Pictographic# NA[1384] (🪖..🿽) .. + +# Total elements: 3793 + +#EOF diff --git a/lib/pleroma/emoji.ex b/lib/pleroma/emoji.ex index 66e20f0e4..3f5169007 100644 --- a/lib/pleroma/emoji.ex +++ b/lib/pleroma/emoji.ex @@ -260,4 +260,29 @@ defp match_group_patterns(group_patterns, matcher) do Enum.any?(patterns, matcher) && group end) end + + {:ok, file} = File.read("lib/pleroma/emoji-data.txt") + + @unicode_emoji file + |> String.split("\n") + |> Enum.filter(fn line -> String.starts_with?(line, ["1", "2", "3", "4"]) end) + |> Enum.map(fn line -> String.split(line) |> List.first() end) + |> Enum.map(fn line -> + case String.split(line, "..") do + [number] -> + String.to_integer(number, 16) + + [first, last] -> + Range.new(String.to_integer(first, 16), String.to_integer(last, 16)) + |> Enum.to_list() + end + end) + |> List.flatten() + |> Enum.filter(&is_integer/1) + |> Enum.uniq() + |> Enum.map(fn n -> :unicode.characters_to_binary([n], :utf32) end) + + def is_unicode_emoji?(str) do + str in @unicode_emoji + end end diff --git a/test/emoji_test.exs b/test/emoji_test.exs index 07ac6ff1d..467357291 100644 --- a/test/emoji_test.exs +++ b/test/emoji_test.exs @@ -6,6 +6,14 @@ defmodule Pleroma.EmojiTest do use ExUnit.Case, async: true alias Pleroma.Emoji + describe "is_unicode_emoji?/1" do + test "tells if a string is an unicode emoji" do + refute Emoji.is_unicode_emoji?("X") + assert Emoji.is_unicode_emoji?("☂") + assert Emoji.is_unicode_emoji?("🥺") + end + end + describe "get_all/0" do setup do emoji_list = Emoji.get_all() From e5b3ad3d049a7c665285f724c53f6cafb0e10118 Mon Sep 17 00:00:00 2001 From: lain Date: Fri, 13 Sep 2019 16:06:34 +0200 Subject: [PATCH 009/154] ActivityPub: Use is_unicode_emoji? function. --- lib/pleroma/web/activity_pub/activity_pub.ex | 2 +- lib/pleroma/web/activity_pub/utils.ex | 4 ---- test/web/pleroma_api/pleroma_api_controller_test.exs | 1 - 3 files changed, 1 insertion(+), 6 deletions(-) diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex index 6cd168427..4ee9b1885 100644 --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@ -315,7 +315,7 @@ def update(%{to: to, cc: cc, actor: actor, object: object} = params) do def react_with_emoji(user, object, emoji, options \\ []) do with local <- Keyword.get(options, :local, true), activity_id <- Keyword.get(options, :activity_id, nil), - is_emoji?(emoji), + Pleroma.Emoji.is_unicode_emoji?(emoji), reaction_data <- make_emoji_reaction_data(user, object, emoji, activity_id), {:ok, activity} <- insert(reaction_data, local), {:ok, object} <- add_emoji_reaction_to_object(activity, object) do diff --git a/lib/pleroma/web/activity_pub/utils.ex b/lib/pleroma/web/activity_pub/utils.ex index 1e6a67deb..95e040c6c 100644 --- a/lib/pleroma/web/activity_pub/utils.ex +++ b/lib/pleroma/web/activity_pub/utils.ex @@ -277,10 +277,6 @@ def get_object_likes(%{data: %{"id" => id}}) do |> Repo.all() end - def is_emoji?(emoji) do - String.length(emoji) == 1 - end - def make_emoji_reaction_data(user, object, emoji, activity_id) do make_like_data(user, object, activity_id) |> Map.put("type", "EmojiReaction") diff --git a/test/web/pleroma_api/pleroma_api_controller_test.exs b/test/web/pleroma_api/pleroma_api_controller_test.exs index 71e4d3e1c..fa85d9174 100644 --- a/test/web/pleroma_api/pleroma_api_controller_test.exs +++ b/test/web/pleroma_api/pleroma_api_controller_test.exs @@ -8,7 +8,6 @@ defmodule Pleroma.Web.PleromaAPI.PleromaAPIControllerTest do alias Pleroma.Conversation.Participation alias Pleroma.Repo alias Pleroma.Web.CommonAPI - alias Pleroma.Web.MastodonAPI.AccountView import Pleroma.Factory From f649a2e972b70dfefb7bfc110b27a0194cda51c5 Mon Sep 17 00:00:00 2001 From: lain Date: Fri, 13 Sep 2019 16:19:50 +0200 Subject: [PATCH 010/154] Pleroma API Docs: Documented Emoji reaction endpoints. --- docs/api/pleroma_api.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/docs/api/pleroma_api.md b/docs/api/pleroma_api.md index b134b31a8..c846df1da 100644 --- a/docs/api/pleroma_api.md +++ b/docs/api/pleroma_api.md @@ -354,3 +354,28 @@ The status posting endpoint takes an additional parameter, `in_reply_to_conversa * Params: * `recipients`: A list of ids of users that should receive posts to this conversation. This will replace the current list of recipients, so submit the full list. The owner of owner of the conversation will always be part of the set of recipients, though. * Response: JSON, statuses (200 - healthy, 503 unhealthy) + +# Emoji Reactions + +Emoji reactions work a lot like favourites do. They make it possible to react to a post with a single emoji character. + +## `POST /api/v1/pleroma/statuses/:id/react_with_emoji` +### React to a post with a unicode emoji +* Method: `POST` +* Authentication: required +* Params: `emoji`: A single character unicode emoji +* Response: JSON, the status. + +## `GET /api/v1/pleroma/statuses/:id/emoji_reactions_by` +### Get an object of emoji to account mappings with accounts that reacted to the post +* Method: `GET` +* Authentication: optional +* Params: None +* Response: JSON, a map of emoji to account list mappings. +* Example Response: +```json +{ + "😀" => [{"id" => "xyz.."...}, {"id" => "zyx..."}], + "🗡" => [{"id" => "abc..."}] +} +``` From 3ff55322201fa7f6b22368988095963fcb82d6e4 Mon Sep 17 00:00:00 2001 From: lain Date: Fri, 13 Sep 2019 16:41:30 +0200 Subject: [PATCH 011/154] Linting. --- lib/pleroma/web/pleroma_api/pleroma_api_controller.ex | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pleroma/web/pleroma_api/pleroma_api_controller.ex b/lib/pleroma/web/pleroma_api/pleroma_api_controller.ex index 110240115..d41091d93 100644 --- a/lib/pleroma/web/pleroma_api/pleroma_api_controller.ex +++ b/lib/pleroma/web/pleroma_api/pleroma_api_controller.ex @@ -8,10 +8,10 @@ defmodule Pleroma.Web.PleromaAPI.PleromaAPIController do import Pleroma.Web.ControllerHelper, only: [add_link_headers: 7] alias Pleroma.Activity - alias Pleroma.Object - alias Pleroma.User alias Pleroma.Conversation.Participation alias Pleroma.Notification + alias Pleroma.Object + alias Pleroma.User alias Pleroma.Web.ActivityPub.ActivityPub alias Pleroma.Web.CommonAPI alias Pleroma.Web.MastodonAPI.AccountView From 6fe2f554c36be1ef03ac1d1104a78d0686f48a26 Mon Sep 17 00:00:00 2001 From: lain Date: Fri, 13 Sep 2019 18:27:32 +0200 Subject: [PATCH 012/154] Emoji: Generate emoji detecting functions at compile time. Suggested by jvalim --- lib/pleroma/emoji.ex | 46 +++++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/lib/pleroma/emoji.ex b/lib/pleroma/emoji.ex index 3f5169007..65f2d5f39 100644 --- a/lib/pleroma/emoji.ex +++ b/lib/pleroma/emoji.ex @@ -261,28 +261,34 @@ defp match_group_patterns(group_patterns, matcher) do end) end - {:ok, file} = File.read("lib/pleroma/emoji-data.txt") + @external_resource "lib/pleroma/emoji-data.txt" - @unicode_emoji file - |> String.split("\n") - |> Enum.filter(fn line -> String.starts_with?(line, ["1", "2", "3", "4"]) end) - |> Enum.map(fn line -> String.split(line) |> List.first() end) - |> Enum.map(fn line -> - case String.split(line, "..") do - [number] -> - String.to_integer(number, 16) + emojis = + @external_resource + |> File.read!() + |> String.split("\n") + |> Enum.filter(fn line -> line != "" and not String.starts_with?(line, "#") end) + |> Enum.map(fn line -> + line + |> String.split(";", parts: 2) + |> hd() + |> String.trim() + |> String.split("..") + |> case do + [number] -> + <> - [first, last] -> - Range.new(String.to_integer(first, 16), String.to_integer(last, 16)) - |> Enum.to_list() - end - end) - |> List.flatten() - |> Enum.filter(&is_integer/1) - |> Enum.uniq() - |> Enum.map(fn n -> :unicode.characters_to_binary([n], :utf32) end) + [first, last] -> + String.to_integer(first, 16)..String.to_integer(last, 16) + |> Enum.map(&<<&1::utf8>>) + end + end) + |> List.flatten() + |> Enum.uniq() - def is_unicode_emoji?(str) do - str in @unicode_emoji + for emoji <- emojis do + def is_unicode_emoji?(unquote(emoji)), do: true end + + def is_unicode_emoji?(_), do: false end From 0aef18bcf4896adbd6bb7ea59e9399cb09dbfa3c Mon Sep 17 00:00:00 2001 From: lain Date: Mon, 30 Sep 2019 14:26:59 +0200 Subject: [PATCH 013/154] Litepub Context: Add EmojiReaction. --- priv/static/schemas/litepub-0.1.jsonld | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/priv/static/schemas/litepub-0.1.jsonld b/priv/static/schemas/litepub-0.1.jsonld index f01c2c33a..5e44ad819 100644 --- a/priv/static/schemas/litepub-0.1.jsonld +++ b/priv/static/schemas/litepub-0.1.jsonld @@ -32,7 +32,8 @@ "uploadMedia": { "@id": "litepub:uploadMedia", "@type": "@id" - } + }, + "EmojiReaction": "litepub:EmojiReaction" } ] } From 04a2910f33405db368687f8749b405eeac06df63 Mon Sep 17 00:00:00 2001 From: lain Date: Mon, 30 Sep 2019 15:13:05 +0200 Subject: [PATCH 014/154] Pleroma.Constants: Fix typo. --- lib/pleroma/constants.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pleroma/constants.ex b/lib/pleroma/constants.ex index 7d775c3c2..1a432e681 100644 --- a/lib/pleroma/constants.ex +++ b/lib/pleroma/constants.ex @@ -10,7 +10,7 @@ defmodule Pleroma.Constants do const(object_internal_fields, do: [ "reactions", - "reactions_count", + "reaction_count", "likes", "like_count", "announcements", From 6068d2254e2ed00260dc840f18824dc0e0835afa Mon Sep 17 00:00:00 2001 From: lain Date: Mon, 30 Sep 2019 15:13:25 +0200 Subject: [PATCH 015/154] PleromaAPIController: Fixes and refactoring. --- .../controllers/pleroma_api_controller.ex | 17 ++++++----------- test/web/activity_pub/transmogrifier_test.exs | 2 +- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/lib/pleroma/web/pleroma_api/controllers/pleroma_api_controller.ex b/lib/pleroma/web/pleroma_api/controllers/pleroma_api_controller.ex index 474b8d079..39d371ff7 100644 --- a/lib/pleroma/web/pleroma_api/controllers/pleroma_api_controller.ex +++ b/lib/pleroma/web/pleroma_api/controllers/pleroma_api_controller.ex @@ -23,17 +23,12 @@ def emoji_reactions_by(%{assigns: %{user: user}} = conn, %{"id" => activity_id}) with %Activity{} = activity <- Activity.get_by_id_with_object(activity_id), %Object{data: %{"reactions" => emoji_reactions}} <- Object.normalize(activity) do reactions = - Enum.reduce(emoji_reactions, %{}, fn {emoji, users}, res -> - users = - users - |> Enum.map(&User.get_cached_by_ap_id/1) - - res - |> Map.put( - emoji, - AccountView.render("accounts.json", %{users: users, for: user, as: :user}) - ) + emoji_reactions + |> Enum.map(fn {emoji, users} -> + users = Enum.map(users, &User.get_cached_by_ap_id/1) + {emoji, AccountView.render("accounts.json", %{users: users, for: user, as: :user})} end) + |> Enum.into(%{}) conn |> json(reactions) @@ -49,7 +44,7 @@ def react_with_emoji(%{assigns: %{user: user}} = conn, %{"id" => activity_id, "e activity = Activity.get_by_id(activity_id) do conn |> put_view(StatusView) - |> render("status.json", %{activity: activity, for: user, as: :activity}) + |> render("show.json", %{activity: activity, for: user, as: :activity}) end end diff --git a/test/web/activity_pub/transmogrifier_test.exs b/test/web/activity_pub/transmogrifier_test.exs index ba2a43296..f1ceb20d2 100644 --- a/test/web/activity_pub/transmogrifier_test.exs +++ b/test/web/activity_pub/transmogrifier_test.exs @@ -1263,7 +1263,7 @@ test "it can handle Listen activities" do {:ok, activity} = CommonAPI.listen(user, %{"title" => "lain radio episode 1"}) - {:ok, modified} = Transmogrifier.prepare_outgoing(activity.data) + {:ok, _modified} = Transmogrifier.prepare_outgoing(activity.data) end end From 08256e9299494c0bcd1a295c6079263277b21ba7 Mon Sep 17 00:00:00 2001 From: lain Date: Mon, 30 Sep 2019 15:51:09 +0200 Subject: [PATCH 016/154] ActivityPub: Federate reactions. --- lib/pleroma/web/activity_pub/activity_pub.ex | 3 ++- test/web/activity_pub/activity_pub_test.exs | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex index 77fa23db4..a6fb67a28 100644 --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@ -313,7 +313,8 @@ def react_with_emoji(user, object, emoji, options \\ []) do Pleroma.Emoji.is_unicode_emoji?(emoji), reaction_data <- make_emoji_reaction_data(user, object, emoji, activity_id), {:ok, activity} <- insert(reaction_data, local), - {:ok, object} <- add_emoji_reaction_to_object(activity, object) do + {:ok, object} <- add_emoji_reaction_to_object(activity, object), + :ok <- maybe_federate(activity) do {:ok, activity, object} end end diff --git a/test/web/activity_pub/activity_pub_test.exs b/test/web/activity_pub/activity_pub_test.exs index 3e6f389bc..4dc7d96d2 100644 --- a/test/web/activity_pub/activity_pub_test.exs +++ b/test/web/activity_pub/activity_pub_test.exs @@ -727,6 +727,18 @@ test "returns reblogs for users for whom reblogs have not been muted" do end describe "react to an object" do + test_with_mock "sends an activity to federation", Pleroma.Web.Federator, [:passthrough], [] do + Pleroma.Config.put([:instance, :federating], true) + user = insert(:user) + reactor = insert(:user) + {:ok, activity} = CommonAPI.post(user, %{"status" => "YASSSS queen slay"}) + assert object = Object.normalize(activity) + + {:ok, reaction_activity, _object} = ActivityPub.react_with_emoji(reactor, object, "🔥") + + assert called(Pleroma.Web.Federator.publish(reaction_activity)) + end + test "adds an emoji reaction activity to the db" do user = insert(:user) reactor = insert(:user) From 19bc0b8c79765dc485e081651a4e4c589d18b970 Mon Sep 17 00:00:00 2001 From: lain Date: Mon, 30 Sep 2019 16:38:19 +0200 Subject: [PATCH 017/154] . --- lib/pleroma/web/activity_pub/activity_pub.ex | 7 +++++++ test/web/activity_pub/activity_pub_test.exs | 14 ++++++++++++++ test/web/common_api/common_api_test.exs | 10 ++++++++++ .../pleroma_api/pleroma_api_controller_test.exs | 16 ++++++++++++++++ 4 files changed, 47 insertions(+) diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex index a6fb67a28..1f201d587 100644 --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@ -319,6 +319,13 @@ def react_with_emoji(user, object, emoji, options \\ []) do end end + def unreact_with_emoji(user, reaction_id, option \\ []) do + with local <- Keyword.get(options, :local, true), + activity_id <- Keyword.get(options, :activity_id, nil), + %Activity{actor: ^user.ap_id} = reaction_activity <- Activity.get_by_ap_id(reaction_id), + unreact_data + end + # TODO: This is weird, maybe we shouldn't check here if we can make the activity. def like( %User{ap_id: ap_id} = user, diff --git a/test/web/activity_pub/activity_pub_test.exs b/test/web/activity_pub/activity_pub_test.exs index 4dc7d96d2..5a6464350 100644 --- a/test/web/activity_pub/activity_pub_test.exs +++ b/test/web/activity_pub/activity_pub_test.exs @@ -760,6 +760,20 @@ test "adds an emoji reaction activity to the db" do end end + describe "unreacting to an object" do + test "adds an emoji reaction activity to the db" do + user = insert(:user) + reactor = insert(:user) + {:ok, activity} = CommonAPI.post(user, %{"status" => "YASSSS queen slay"}) + assert object = Object.normalize(activity) + + {:ok, reaction_activity, object} = ActivityPub.react_with_emoji(reactor, object, "🔥") + {:ok, unreaction_activity} = ActivityPub.unreact_with_emoji(reactor, reaction_activity.id) + + IO.inspect(object) + end + end + describe "like an object" do test_with_mock "sends an activity to federation", Pleroma.Web.Federator, [:passthrough], [] do Pleroma.Config.put([:instance, :federating], true) diff --git a/test/web/common_api/common_api_test.exs b/test/web/common_api/common_api_test.exs index 011fcfca9..9e3bf6cc8 100644 --- a/test/web/common_api/common_api_test.exs +++ b/test/web/common_api/common_api_test.exs @@ -236,6 +236,16 @@ test "reacting to a status with an emoji" do # TODO: test error case. end + test "unreacting to a status with an emoji" do + user = insert(:user) + other_user = insert(:user) + + {:ok, activity} = CommonAPI.post(other_user, %{"status" => "cofe"}) + {:ok, reaction, _} = CommonAPI.react_with_emoji(activity.id, user, "👍") + + assert false + end + test "repeating a status" do user = insert(:user) other_user = insert(:user) diff --git a/test/web/pleroma_api/pleroma_api_controller_test.exs b/test/web/pleroma_api/pleroma_api_controller_test.exs index 3c2a087ca..82d23ea5b 100644 --- a/test/web/pleroma_api/pleroma_api_controller_test.exs +++ b/test/web/pleroma_api/pleroma_api_controller_test.exs @@ -27,6 +27,22 @@ test "POST /api/v1/pleroma/statuses/:id/react_with_emoji", %{conn: conn} do assert to_string(activity.id) == id end + test "POST /api/v1/pleroma/statuses/:id/unreact_with_emoji", %{conn: conn} do + user = insert(:user) + other_user = insert(:user) + + {:ok, activity} = CommonAPI.post(user, %{"status" => "#cofe"}) + {:ok, activity, _object} = CommonAPI.react_with_emoji(activity.id, other_user, "☕") + + result = + conn + |> assign(:user, other_user) + |> post("/api/v1/pleroma/statuses/#{activity.id}/unreact_with_emoji", %{"emoji" => "☕"}) + + assert %{"id" => id} = json_response(result, 200) + assert to_string(activity.id) == id + end + test "GET /api/v1/pleroma/statuses/:id/emoji_reactions_by", %{conn: conn} do user = insert(:user) other_user = insert(:user) From dfe5c958eb94326f5a7743c9de0de073260db926 Mon Sep 17 00:00:00 2001 From: lain Date: Wed, 2 Oct 2019 15:08:20 +0200 Subject: [PATCH 018/154] ActivityPub: Add undo for emoji reactions. --- lib/pleroma/web/activity_pub/activity_pub.ex | 13 +++++-- lib/pleroma/web/activity_pub/utils.ex | 37 ++++++++++++++++++++ lib/pleroma/web/router.ex | 2 -- test/web/activity_pub/activity_pub_test.exs | 32 ++++++++++++++--- 4 files changed, 75 insertions(+), 9 deletions(-) diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex index a9e53141d..458d3590d 100644 --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@ -319,11 +319,18 @@ def react_with_emoji(user, object, emoji, options \\ []) do end end - def unreact_with_emoji(user, reaction_id, option \\ []) do + def unreact_with_emoji(user, reaction_id, options \\ []) do with local <- Keyword.get(options, :local, true), activity_id <- Keyword.get(options, :activity_id, nil), - %Activity{actor: ^user.ap_id} = reaction_activity <- Activity.get_by_ap_id(reaction_id), - unreact_data + user_ap_id <- user.ap_id, + %Activity{actor: ^user_ap_id} = reaction_activity <- Activity.get_by_ap_id(reaction_id), + object <- Object.normalize(reaction_activity), + unreact_data <- make_undo_data(user, reaction_activity, activity_id), + {:ok, activity} <- insert(unreact_data, local), + {:ok, object} <- remove_emoji_reaction_from_object(reaction_activity, object), + :ok <- maybe_federate(activity) do + {:ok, activity, object} + end end # TODO: This is weird, maybe we shouldn't check here if we can make the activity. diff --git a/lib/pleroma/web/activity_pub/utils.ex b/lib/pleroma/web/activity_pub/utils.ex index 4c146fd86..7807fa9cd 100644 --- a/lib/pleroma/web/activity_pub/utils.ex +++ b/lib/pleroma/web/activity_pub/utils.ex @@ -337,6 +337,24 @@ def add_emoji_reaction_to_object( update_element_in_object("reaction", new_reactions, object) end + def remove_emoji_reaction_from_object( + %Activity{data: %{"content" => emoji, "actor" => actor}}, + object + ) do + reactions = object.data["reactions"] || %{} + emoji_actors = reactions[emoji] || [] + new_emoji_actors = List.delete(emoji_actors, actor) + + new_reactions = + if new_emoji_actors == [] do + Map.delete(reactions, emoji) + else + Map.put(reactions, emoji, new_emoji_actors) + end + + update_element_in_object("reaction", new_reactions, object) + end + @spec add_like_to_object(Activity.t(), Object.t()) :: {:ok, Object.t()} | {:error, Ecto.Changeset.t()} def add_like_to_object(%Activity{data: %{"actor" => actor}}, object) do @@ -522,6 +540,25 @@ def make_unlike_data( |> maybe_put("id", activity_id) end + def make_undo_data( + %User{ap_id: actor, follower_address: follower_address}, + %Activity{ + data: %{"id" => undone_activity_id, "context" => context}, + actor: undone_activity_actor + }, + activity_id \\ nil + ) do + %{ + "type" => "Undo", + "actor" => actor, + "object" => undone_activity_id, + "to" => [follower_address, undone_activity_actor], + "cc" => [Pleroma.Constants.as_public()], + "context" => context + } + |> maybe_put("id", activity_id) + end + @spec add_announce_to_object(Activity.t(), Object.t()) :: {:ok, Object.t()} | {:error, Ecto.Changeset.t()} def add_announce_to_object( diff --git a/lib/pleroma/web/router.ex b/lib/pleroma/web/router.ex index eae1f676b..ff3dc273e 100644 --- a/lib/pleroma/web/router.ex +++ b/lib/pleroma/web/router.ex @@ -293,8 +293,6 @@ defmodule Pleroma.Web.Router do end scope "/api/v1/pleroma", Pleroma.Web.PleromaAPI do - pipe_through(:authenticated_api) - scope [] do pipe_through(:authenticated_api) pipe_through(:oauth_read) diff --git a/test/web/activity_pub/activity_pub_test.exs b/test/web/activity_pub/activity_pub_test.exs index 8c9c2c89e..36a82d6a1 100644 --- a/test/web/activity_pub/activity_pub_test.exs +++ b/test/web/activity_pub/activity_pub_test.exs @@ -761,16 +761,40 @@ test "adds an emoji reaction activity to the db" do end describe "unreacting to an object" do - test "adds an emoji reaction activity to the db" do + test_with_mock "sends an activity to federation", Pleroma.Web.Federator, [:passthrough], [] do + Pleroma.Config.put([:instance, :federating], true) user = insert(:user) reactor = insert(:user) {:ok, activity} = CommonAPI.post(user, %{"status" => "YASSSS queen slay"}) assert object = Object.normalize(activity) - {:ok, reaction_activity, object} = ActivityPub.react_with_emoji(reactor, object, "🔥") - {:ok, unreaction_activity} = ActivityPub.unreact_with_emoji(reactor, reaction_activity.id) + {:ok, reaction_activity, _object} = ActivityPub.react_with_emoji(reactor, object, "🔥") - IO.inspect(object) + assert called(Pleroma.Web.Federator.publish(reaction_activity)) + + {:ok, unreaction_activity, _object} = + ActivityPub.unreact_with_emoji(reactor, reaction_activity.data["id"]) + + assert called(Pleroma.Web.Federator.publish(unreaction_activity)) + end + + test "adds an undo activity to the db" do + user = insert(:user) + reactor = insert(:user) + {:ok, activity} = CommonAPI.post(user, %{"status" => "YASSSS queen slay"}) + assert object = Object.normalize(activity) + + {:ok, reaction_activity, _object} = ActivityPub.react_with_emoji(reactor, object, "🔥") + + {:ok, unreaction_activity, _object} = + ActivityPub.unreact_with_emoji(reactor, reaction_activity.data["id"]) + + assert unreaction_activity.actor == reactor.ap_id + assert unreaction_activity.data["object"] == reaction_activity.data["id"] + + object = Object.get_by_ap_id(object.data["id"]) + assert object.data["reaction_count"] == 0 + assert object.data["reactions"] == %{} end end From 9cfe9a57c5a31318abf02fa510d4fdf78505bd97 Mon Sep 17 00:00:00 2001 From: lain Date: Wed, 2 Oct 2019 15:38:57 +0200 Subject: [PATCH 019/154] CommonAPI: Add unreactions. --- lib/pleroma/web/activity_pub/utils.ex | 13 +++++++++++++ lib/pleroma/web/common_api/common_api.ex | 9 +++++++++ test/web/common_api/common_api_test.exs | 5 ++++- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/lib/pleroma/web/activity_pub/utils.ex b/lib/pleroma/web/activity_pub/utils.ex index 7807fa9cd..82e2d8f76 100644 --- a/lib/pleroma/web/activity_pub/utils.ex +++ b/lib/pleroma/web/activity_pub/utils.ex @@ -452,6 +452,19 @@ def fetch_latest_follow(%User{ap_id: follower_id}, %User{ap_id: followed_id}) do |> Repo.one() end + def get_latest_reaction(internal_activity_id, %{ap_id: ap_id}, emoji) do + %{data: %{"object" => object_ap_id}} = Activity.get_by_id(internal_activity_id) + + "EmojiReaction" + |> Activity.Queries.by_type() + |> where(actor: ^ap_id) + |> where([activity], fragment("?->>'content' = ?", activity.data, ^emoji)) + |> Activity.Queries.by_object_id(object_ap_id) + |> order_by([activity], fragment("? desc nulls last", activity.id)) + |> limit(1) + |> Repo.one() + end + #### Announce-related helpers @doc """ diff --git a/lib/pleroma/web/common_api/common_api.ex b/lib/pleroma/web/common_api/common_api.ex index 53ada8fab..995d4b1af 100644 --- a/lib/pleroma/web/common_api/common_api.ex +++ b/lib/pleroma/web/common_api/common_api.ex @@ -125,6 +125,15 @@ def react_with_emoji(id, user, emoji) do end end + def unreact_with_emoji(id, user, emoji) do + with %Activity{} = reaction_activity <- Utils.get_latest_reaction(id, user, emoji) do + ActivityPub.unreact_with_emoji(user, reaction_activity.data["id"]) + else + _ -> + {:error, dgettext("errors", "Could not remove reaction emoji")} + end + end + def vote(user, %{data: %{"type" => "Question"}} = object, choices) do with :ok <- validate_not_author(object, user), :ok <- validate_existing_votes(user, object), diff --git a/test/web/common_api/common_api_test.exs b/test/web/common_api/common_api_test.exs index e048ed217..b9e785885 100644 --- a/test/web/common_api/common_api_test.exs +++ b/test/web/common_api/common_api_test.exs @@ -243,7 +243,10 @@ test "unreacting to a status with an emoji" do {:ok, activity} = CommonAPI.post(other_user, %{"status" => "cofe"}) {:ok, reaction, _} = CommonAPI.react_with_emoji(activity.id, user, "👍") - assert false + {:ok, unreaction, _} = CommonAPI.unreact_with_emoji(activity.id, user, "👍") + + assert unreaction.data["type"] == "Undo" + assert unreaction.data["object"] == reaction.data["id"] end test "repeating a status" do From 391c7362921ba94a0084b7a25c4126ce7026dc55 Mon Sep 17 00:00:00 2001 From: lain Date: Wed, 2 Oct 2019 18:13:10 +0200 Subject: [PATCH 020/154] PleromaAPI: Fix emoji_reactions_by --- .../web/pleroma_api/controllers/pleroma_api_controller.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pleroma/web/pleroma_api/controllers/pleroma_api_controller.ex b/lib/pleroma/web/pleroma_api/controllers/pleroma_api_controller.ex index 39d371ff7..884b3d877 100644 --- a/lib/pleroma/web/pleroma_api/controllers/pleroma_api_controller.ex +++ b/lib/pleroma/web/pleroma_api/controllers/pleroma_api_controller.ex @@ -26,7 +26,7 @@ def emoji_reactions_by(%{assigns: %{user: user}} = conn, %{"id" => activity_id}) emoji_reactions |> Enum.map(fn {emoji, users} -> users = Enum.map(users, &User.get_cached_by_ap_id/1) - {emoji, AccountView.render("accounts.json", %{users: users, for: user, as: :user})} + {emoji, AccountView.render("index.json", %{users: users, for: user, as: :user})} end) |> Enum.into(%{}) From 4cb603e1df7c9d13db1aa4285e2a18b9be71cd78 Mon Sep 17 00:00:00 2001 From: lain Date: Wed, 2 Oct 2019 18:19:16 +0200 Subject: [PATCH 021/154] PleromaAPI: Add unreacting. --- .../controllers/pleroma_api_controller.ex | 14 +++++++++++++- lib/pleroma/web/router.ex | 1 + .../controllers/pleroma_api_controller_test.exs | 5 +++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/pleroma/web/pleroma_api/controllers/pleroma_api_controller.ex b/lib/pleroma/web/pleroma_api/controllers/pleroma_api_controller.ex index 884b3d877..8aee7d7c5 100644 --- a/lib/pleroma/web/pleroma_api/controllers/pleroma_api_controller.ex +++ b/lib/pleroma/web/pleroma_api/controllers/pleroma_api_controller.ex @@ -41,7 +41,19 @@ def emoji_reactions_by(%{assigns: %{user: user}} = conn, %{"id" => activity_id}) def react_with_emoji(%{assigns: %{user: user}} = conn, %{"id" => activity_id, "emoji" => emoji}) do with {:ok, _activity, _object} <- CommonAPI.react_with_emoji(activity_id, user, emoji), - activity = Activity.get_by_id(activity_id) do + activity <- Activity.get_by_id(activity_id) do + conn + |> put_view(StatusView) + |> render("show.json", %{activity: activity, for: user, as: :activity}) + end + end + + def unreact_with_emoji(%{assigns: %{user: user}} = conn, %{ + "id" => activity_id, + "emoji" => emoji + }) do + with {:ok, _activity, _object} <- CommonAPI.unreact_with_emoji(activity_id, user, emoji), + activity <- Activity.get_by_id(activity_id) do conn |> put_view(StatusView) |> render("show.json", %{activity: activity, for: user, as: :activity}) diff --git a/lib/pleroma/web/router.ex b/lib/pleroma/web/router.ex index ff3dc273e..87d373f55 100644 --- a/lib/pleroma/web/router.ex +++ b/lib/pleroma/web/router.ex @@ -305,6 +305,7 @@ defmodule Pleroma.Web.Router do pipe_through(:oauth_write) patch("/conversations/:id", PleromaAPIController, :update_conversation) post("/statuses/:id/react_with_emoji", PleromaAPIController, :react_with_emoji) + post("/statuses/:id/unreact_with_emoji", PleromaAPIController, :unreact_with_emoji) post("/notifications/read", PleromaAPIController, :read_notification) patch("/accounts/update_avatar", AccountController, :update_avatar) diff --git a/test/web/pleroma_api/controllers/pleroma_api_controller_test.exs b/test/web/pleroma_api/controllers/pleroma_api_controller_test.exs index 82d23ea5b..3a5dbdeea 100644 --- a/test/web/pleroma_api/controllers/pleroma_api_controller_test.exs +++ b/test/web/pleroma_api/controllers/pleroma_api_controller_test.exs @@ -7,6 +7,7 @@ defmodule Pleroma.Web.PleromaAPI.PleromaAPIControllerTest do alias Pleroma.Conversation.Participation alias Pleroma.Notification + alias Pleroma.Object alias Pleroma.Repo alias Pleroma.Web.CommonAPI @@ -41,6 +42,10 @@ test "POST /api/v1/pleroma/statuses/:id/unreact_with_emoji", %{conn: conn} do assert %{"id" => id} = json_response(result, 200) assert to_string(activity.id) == id + + object = Object.normalize(activity) + + assert object.data["reaction_count"] == 0 end test "GET /api/v1/pleroma/statuses/:id/emoji_reactions_by", %{conn: conn} do From 0e41951eab405ea5a3016bbb0897eba4aa7c6a0b Mon Sep 17 00:00:00 2001 From: lain Date: Wed, 2 Oct 2019 18:20:40 +0200 Subject: [PATCH 022/154] Pleroma API Readme: Document unreaction endpoint. --- docs/api/pleroma_api.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/api/pleroma_api.md b/docs/api/pleroma_api.md index 7862e6301..e672aec96 100644 --- a/docs/api/pleroma_api.md +++ b/docs/api/pleroma_api.md @@ -483,6 +483,13 @@ Emoji reactions work a lot like favourites do. They make it possible to react to * Params: `emoji`: A single character unicode emoji * Response: JSON, the status. +## `POST /api/v1/pleroma/statuses/:id/unreact_with_emoji` +### Remove a reaction to a post with a unicode emoji +* Method: `POST` +* Authentication: required +* Params: `emoji`: A single character unicode emoji +* Response: JSON, the status. + ## `GET /api/v1/pleroma/statuses/:id/emoji_reactions_by` ### Get an object of emoji to account mappings with accounts that reacted to the post * Method: `GET` From c9043c6c808129f4f6236d03bf05e5a46f0c6e14 Mon Sep 17 00:00:00 2001 From: lain Date: Thu, 3 Oct 2019 18:37:23 +0200 Subject: [PATCH 023/154] Transmogrifier: Handle incoming Undos for EmojiReactions. --- .../web/activity_pub/transmogrifier.ex | 22 +++++++++++++++++++ test/web/activity_pub/transmogrifier_test.exs | 20 ++++++++++++++++- 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/lib/pleroma/web/activity_pub/transmogrifier.ex b/lib/pleroma/web/activity_pub/transmogrifier.ex index cb868c336..ea209b5ea 100644 --- a/lib/pleroma/web/activity_pub/transmogrifier.ex +++ b/lib/pleroma/web/activity_pub/transmogrifier.ex @@ -721,6 +721,28 @@ def handle_incoming( end end + def handle_incoming( + %{ + "type" => "Undo", + "object" => %{"type" => "EmojiReaction", "id" => reaction_activity_id}, + "actor" => _actor, + "id" => id + } = data, + _options + ) do + with actor <- Containment.get_actor(data), + {:ok, %User{} = actor} <- User.get_or_fetch_by_ap_id(actor), + {:ok, activity, _} <- + ActivityPub.unreact_with_emoji(actor, reaction_activity_id, + activity_id: id, + local: false + ) do + {:ok, activity} + else + _e -> :error + end + end + def handle_incoming( %{ "type" => "Undo", diff --git a/test/web/activity_pub/transmogrifier_test.exs b/test/web/activity_pub/transmogrifier_test.exs index 5bb435457..a9544caf2 100644 --- a/test/web/activity_pub/transmogrifier_test.exs +++ b/test/web/activity_pub/transmogrifier_test.exs @@ -359,6 +359,25 @@ test "it works for incoming emoji reactions" do assert data["content"] == "👌" end + test "it works for incoming emoji reaction undos" do + user = insert(:user) + + {:ok, activity} = CommonAPI.post(user, %{"status" => "hello"}) + {:ok, reaction_activity, _object} = CommonAPI.react_with_emoji(activity.id, user, "👌") + + data = + File.read!("test/fixtures/mastodon-undo-like.json") + |> Poison.decode!() + |> Map.put("object", reaction_activity.data["id"]) + |> Map.put("actor", user.ap_id) + + {:ok, activity} = Transmogrifier.handle_incoming(data) + + assert activity.actor == user.ap_id + assert activity.data["id"] == data["id"] + assert activity.data["type"] == "Undo" + end + test "it returns an error for incoming unlikes wihout a like activity" do user = insert(:user) {:ok, activity} = CommonAPI.post(user, %{"status" => "leave a like pls"}) @@ -1116,7 +1135,6 @@ test "it inlines private announced objects" do {:ok, announce_activity, _} = CommonAPI.repeat(activity.id, user) {:ok, modified} = Transmogrifier.prepare_outgoing(announce_activity.data) - object = modified["object"] assert modified["object"]["content"] == "hey" assert modified["object"]["actor"] == modified["object"]["attributedTo"] From 8e83c8423fa846e82103b20798f0cbde676354ff Mon Sep 17 00:00:00 2001 From: lain Date: Fri, 4 Oct 2019 14:49:59 +0200 Subject: [PATCH 024/154] Update Changelog. --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a71a9dae6..35c062dcf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Pleroma API: `GET /api/v1/pleroma/accounts/:id/scrobbles` to get a list of recently scrobbled items - Pleroma API: `POST /api/v1/pleroma/scrobble` to scrobble a media item - Mastodon API: Add `upload_limit`, `avatar_upload_limit`, `background_upload_limit`, and `banner_upload_limit` to `/api/v1/instance` +- Pleroma API: Add Emoji reactions ### Changed - **Breaking:** Elixir >=1.8 is now required (was >= 1.7) From 43a211bcb111720622a89da3016372f5a3a12184 Mon Sep 17 00:00:00 2001 From: lain Date: Fri, 4 Oct 2019 17:01:04 +0200 Subject: [PATCH 025/154] Transmogrifier: Handle misskey likes with reactions like EmojiReactions. --- .../web/activity_pub/transmogrifier.ex | 27 +++++++++++++++++++ test/fixtures/misskey-like.json | 14 ++++++++++ test/web/activity_pub/transmogrifier_test.exs | 18 +++++++++++++ 3 files changed, 59 insertions(+) create mode 100644 test/fixtures/misskey-like.json diff --git a/lib/pleroma/web/activity_pub/transmogrifier.ex b/lib/pleroma/web/activity_pub/transmogrifier.ex index ea209b5ea..54c18bc0e 100644 --- a/lib/pleroma/web/activity_pub/transmogrifier.ex +++ b/lib/pleroma/web/activity_pub/transmogrifier.ex @@ -560,6 +560,33 @@ def handle_incoming( end end + @misskey_reactions %{ + "like" => "👍", + "love" => "❤️", + "laugh" => "😆", + "hmm" => "🤔", + "surprise" => "😮", + "congrats" => "🎉", + "angry" => "💢", + "confused" => "😥", + "rip" => "😇", + "pudding" => "🍮" + } + + @doc "Rewrite misskey likes into EmojiReactions" + def handle_incoming( + %{ + "type" => "Like", + "_misskey_reaction" => reaction + } = data, + options + ) do + data + |> Map.put("type", "EmojiReaction") + |> Map.put("content", @misskey_reactions[reaction]) + |> handle_incoming(options) + end + def handle_incoming( %{"type" => "Like", "object" => object_id, "actor" => _actor, "id" => id} = data, _options diff --git a/test/fixtures/misskey-like.json b/test/fixtures/misskey-like.json new file mode 100644 index 000000000..84d56f473 --- /dev/null +++ b/test/fixtures/misskey-like.json @@ -0,0 +1,14 @@ +{ + "@context" : [ + "https://www.w3.org/ns/activitystreams", + "https://w3id.org/security/v1", + {"Hashtag" : "as:Hashtag"} + ], + "_misskey_reaction" : "pudding", + "actor": "http://mastodon.example.org/users/admin", + "cc" : ["https://testing.pleroma.lol/users/lain"], + "id" : "https://misskey.xyz/75149198-2f45-46e4-930a-8b0538297075", + "nickname" : "lain", + "object" : "https://testing.pleroma.lol/objects/c331bbf7-2eb9-4801-a709-2a6103492a5a", + "type" : "Like" +} diff --git a/test/web/activity_pub/transmogrifier_test.exs b/test/web/activity_pub/transmogrifier_test.exs index a9544caf2..530a762fa 100644 --- a/test/web/activity_pub/transmogrifier_test.exs +++ b/test/web/activity_pub/transmogrifier_test.exs @@ -341,6 +341,24 @@ test "it works for incoming likes" do assert data["object"] == activity.data["object"] end + test "it works for incoming misskey likes, turning them into EmojiReactions" do + user = insert(:user) + {:ok, activity} = CommonAPI.post(user, %{"status" => "hello"}) + + data = + File.read!("test/fixtures/misskey-like.json") + |> Poison.decode!() + |> Map.put("object", activity.data["object"]) + + {:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data) + + assert data["actor"] == data["actor"] + assert data["type"] == "EmojiReaction" + assert data["id"] == data["id"] + assert data["object"] == activity.data["object"] + assert data["content"] == "🍮" + end + test "it works for incoming emoji reactions" do user = insert(:user) {:ok, activity} = CommonAPI.post(user, %{"status" => "hello"}) From 6a85f7d1eabd957588a2f9b8dfea5b7f982573be Mon Sep 17 00:00:00 2001 From: lain Date: Sat, 5 Oct 2019 10:45:42 +0200 Subject: [PATCH 026/154] Transmogrifier: Extend misskey like compatibility. --- .../web/activity_pub/transmogrifier.ex | 5 +++-- test/web/activity_pub/transmogrifier_test.exs | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/lib/pleroma/web/activity_pub/transmogrifier.ex b/lib/pleroma/web/activity_pub/transmogrifier.ex index 54c18bc0e..2c6edb0b1 100644 --- a/lib/pleroma/web/activity_pub/transmogrifier.ex +++ b/lib/pleroma/web/activity_pub/transmogrifier.ex @@ -570,7 +570,8 @@ def handle_incoming( "angry" => "💢", "confused" => "😥", "rip" => "😇", - "pudding" => "🍮" + "pudding" => "🍮", + "star" => "⭐" } @doc "Rewrite misskey likes into EmojiReactions" @@ -583,7 +584,7 @@ def handle_incoming( ) do data |> Map.put("type", "EmojiReaction") - |> Map.put("content", @misskey_reactions[reaction]) + |> Map.put("content", @misskey_reactions[reaction] || reaction) |> handle_incoming(options) end diff --git a/test/web/activity_pub/transmogrifier_test.exs b/test/web/activity_pub/transmogrifier_test.exs index 530a762fa..9156b23e3 100644 --- a/test/web/activity_pub/transmogrifier_test.exs +++ b/test/web/activity_pub/transmogrifier_test.exs @@ -359,6 +359,25 @@ test "it works for incoming misskey likes, turning them into EmojiReactions" do assert data["content"] == "🍮" end + test "it works for incoming misskey likes that contain unicode emojis, turning them into EmojiReactions" do + user = insert(:user) + {:ok, activity} = CommonAPI.post(user, %{"status" => "hello"}) + + data = + File.read!("test/fixtures/misskey-like.json") + |> Poison.decode!() + |> Map.put("object", activity.data["object"]) + |> Map.put("_misskey_reaction", "⭐") + + {:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data) + + assert data["actor"] == data["actor"] + assert data["type"] == "EmojiReaction" + assert data["id"] == data["id"] + assert data["object"] == activity.data["object"] + assert data["content"] == "⭐" + end + test "it works for incoming emoji reactions" do user = insert(:user) {:ok, activity} = CommonAPI.post(user, %{"status" => "hello"}) From d580eedfe93ef08fea7869945c0fd4fe908cb82d Mon Sep 17 00:00:00 2001 From: lain Date: Mon, 7 Oct 2019 12:40:33 +0200 Subject: [PATCH 027/154] Linting. --- .../web/pleroma_api/controllers/pleroma_api_controller.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pleroma/web/pleroma_api/controllers/pleroma_api_controller.ex b/lib/pleroma/web/pleroma_api/controllers/pleroma_api_controller.ex index 16c581a95..6db213475 100644 --- a/lib/pleroma/web/pleroma_api/controllers/pleroma_api_controller.ex +++ b/lib/pleroma/web/pleroma_api/controllers/pleroma_api_controller.ex @@ -11,8 +11,8 @@ defmodule Pleroma.Web.PleromaAPI.PleromaAPIController do alias Pleroma.Conversation.Participation alias Pleroma.Notification alias Pleroma.Object - alias Pleroma.User alias Pleroma.Plugs.OAuthScopesPlug + alias Pleroma.User alias Pleroma.Web.ActivityPub.ActivityPub alias Pleroma.Web.CommonAPI alias Pleroma.Web.MastodonAPI.AccountView From 90d516d42bd3d29e71e364535dd4208f8a54992a Mon Sep 17 00:00:00 2001 From: Maxim Filippov Date: Tue, 15 Oct 2019 16:52:41 +0200 Subject: [PATCH 028/154] Store status data inside flag activity --- lib/pleroma/web/activity_pub/utils.ex | 30 ++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/lib/pleroma/web/activity_pub/utils.ex b/lib/pleroma/web/activity_pub/utils.ex index 4ef479f96..57982eb4a 100644 --- a/lib/pleroma/web/activity_pub/utils.ex +++ b/lib/pleroma/web/activity_pub/utils.ex @@ -609,9 +609,33 @@ def make_flag_data(_, _), do: %{} defp build_flag_object(%{account: account, statuses: statuses} = _) do [account.ap_id] ++ Enum.map(statuses || [], fn - %Activity{} = act -> act.data["id"] - act when is_map(act) -> act["id"] - act when is_binary(act) -> act + %Activity{} = act -> + obj = Object.get_by_ap_id(act.data["object"]) + + %{ + "type" => "Note", + "id" => act.data["id"], + "content" => obj.data["content"] + } + + act when is_map(act) -> + obj = Object.get_by_ap_id(act["object"]) + + %{ + "type" => "Note", + "id" => act["id"], + "content" => obj.data["content"] + } + + act + when is_binary(act) -> + activity = Activity.get_by_ap_id_with_object(act) + + %{ + "type" => "Note", + "id" => activity.data["id"], + "content" => activity.data["object"]["content"] + } end) end From b08b1d5d91968fbe94e20897ee3529216dd50a0a Mon Sep 17 00:00:00 2001 From: Maxim Filippov Date: Wed, 23 Oct 2019 21:27:22 +0200 Subject: [PATCH 029/154] Store status data inside Flag activity --- lib/pleroma/web/activity_pub/utils.ex | 43 ++++++++----------- lib/pleroma/web/admin_api/report.ex | 4 +- test/web/activity_pub/activity_pub_test.exs | 13 +++++- test/web/activity_pub/transmogrifier_test.exs | 13 +++++- test/web/activity_pub/utils_test.exs | 11 ++++- test/web/common_api/common_api_test.exs | 11 ++++- 6 files changed, 62 insertions(+), 33 deletions(-) diff --git a/lib/pleroma/web/activity_pub/utils.ex b/lib/pleroma/web/activity_pub/utils.ex index 57982eb4a..c58ee7482 100644 --- a/lib/pleroma/web/activity_pub/utils.ex +++ b/lib/pleroma/web/activity_pub/utils.ex @@ -12,6 +12,7 @@ defmodule Pleroma.Web.ActivityPub.Utils do alias Pleroma.User alias Pleroma.Web alias Pleroma.Web.ActivityPub.Visibility + alias Pleroma.Web.AdminAPI.AccountView alias Pleroma.Web.Endpoint alias Pleroma.Web.Router.Helpers @@ -608,34 +609,24 @@ def make_flag_data(_, _), do: %{} defp build_flag_object(%{account: account, statuses: statuses} = _) do [account.ap_id] ++ - Enum.map(statuses || [], fn - %Activity{} = act -> - obj = Object.get_by_ap_id(act.data["object"]) + Enum.map(statuses || [], fn act -> + id = + case act do + %Activity{} = act -> act.data["id"] + act when is_map(act) -> act["id"] + act when is_binary(act) -> act + end - %{ - "type" => "Note", - "id" => act.data["id"], - "content" => obj.data["content"] - } + activity = Activity.get_by_ap_id_with_object(id) + actor = User.get_by_ap_id(activity.object.data["actor"]) - act when is_map(act) -> - obj = Object.get_by_ap_id(act["object"]) - - %{ - "type" => "Note", - "id" => act["id"], - "content" => obj.data["content"] - } - - act - when is_binary(act) -> - activity = Activity.get_by_ap_id_with_object(act) - - %{ - "type" => "Note", - "id" => activity.data["id"], - "content" => activity.data["object"]["content"] - } + %{ + "type" => "Note", + "id" => activity.data["id"], + "content" => activity.object.data["content"], + "published" => activity.object.data["published"], + "actor" => AccountView.render("show.json", %{user: actor}) + } end) end diff --git a/lib/pleroma/web/admin_api/report.ex b/lib/pleroma/web/admin_api/report.ex index c751dc2be..ccd56e15e 100644 --- a/lib/pleroma/web/admin_api/report.ex +++ b/lib/pleroma/web/admin_api/report.ex @@ -13,8 +13,8 @@ def extract_report_info( account = User.get_cached_by_ap_id(account_ap_id) statuses = - Enum.map(status_ap_ids, fn ap_id -> - Activity.get_by_ap_id_with_object(ap_id) + Enum.map(status_ap_ids, fn act -> + Activity.get_by_ap_id_with_object(act["id"]) end) %{report: report, user: user, account: account, statuses: statuses} diff --git a/test/web/activity_pub/activity_pub_test.exs b/test/web/activity_pub/activity_pub_test.exs index 3a5a2f984..cbd81b698 100644 --- a/test/web/activity_pub/activity_pub_test.exs +++ b/test/web/activity_pub/activity_pub_test.exs @@ -10,6 +10,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do alias Pleroma.User alias Pleroma.Web.ActivityPub.ActivityPub alias Pleroma.Web.ActivityPub.Utils + alias Pleroma.Web.AdminAPI.AccountView alias Pleroma.Web.CommonAPI import Pleroma.Factory @@ -1265,6 +1266,8 @@ test "it can create a Flag activity" do target_ap_id = target_account.ap_id activity_ap_id = activity.data["id"] + activity_with_object = Activity.get_by_ap_id_with_object(activity_ap_id) + assert {:ok, activity} = ActivityPub.flag(%{ actor: reporter, @@ -1274,13 +1277,21 @@ test "it can create a Flag activity" do content: content }) + note_obj = %{ + "type" => "Note", + "id" => activity_ap_id, + "content" => content, + "published" => activity_with_object.object.data["published"], + "actor" => AccountView.render("show.json", %{user: target_account}) + } + assert %Activity{ actor: ^reporter_ap_id, data: %{ "type" => "Flag", "content" => ^content, "context" => ^context, - "object" => [^target_ap_id, ^activity_ap_id] + "object" => [^target_ap_id, ^note_obj] } } = activity end diff --git a/test/web/activity_pub/transmogrifier_test.exs b/test/web/activity_pub/transmogrifier_test.exs index 6c35a6f4d..82389b344 100644 --- a/test/web/activity_pub/transmogrifier_test.exs +++ b/test/web/activity_pub/transmogrifier_test.exs @@ -12,6 +12,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do alias Pleroma.User alias Pleroma.Web.ActivityPub.ActivityPub alias Pleroma.Web.ActivityPub.Transmogrifier + alias Pleroma.Web.AdminAPI.AccountView alias Pleroma.Web.CommonAPI alias Pleroma.Web.OStatus alias Pleroma.Web.Websub.WebsubClientSubscription @@ -1093,10 +1094,18 @@ test "it accepts Flag activities" do {:ok, activity} = CommonAPI.post(user, %{"status" => "test post"}) object = Object.normalize(activity) + note_obj = %{ + "type" => "Note", + "id" => activity.data["id"], + "content" => "test post", + "published" => object.data["published"], + "actor" => AccountView.render("show.json", %{user: user}) + } + message = %{ "@context" => "https://www.w3.org/ns/activitystreams", "cc" => [user.ap_id], - "object" => [user.ap_id, object.data["id"]], + "object" => [user.ap_id, activity], "type" => "Flag", "content" => "blocked AND reported!!!", "actor" => other_user.ap_id @@ -1104,7 +1113,7 @@ test "it accepts Flag activities" do assert {:ok, activity} = Transmogrifier.handle_incoming(message) - assert activity.data["object"] == [user.ap_id, object.data["id"]] + assert activity.data["object"] == [user.ap_id, note_obj] assert activity.data["content"] == "blocked AND reported!!!" assert activity.data["actor"] == other_user.ap_id assert activity.data["cc"] == [user.ap_id] diff --git a/test/web/activity_pub/utils_test.exs b/test/web/activity_pub/utils_test.exs index c57ea7eb9..4475d06d2 100644 --- a/test/web/activity_pub/utils_test.exs +++ b/test/web/activity_pub/utils_test.exs @@ -10,6 +10,7 @@ defmodule Pleroma.Web.ActivityPub.UtilsTest do alias Pleroma.User alias Pleroma.Web.ActivityPub.ActivityPub alias Pleroma.Web.ActivityPub.Utils + alias Pleroma.Web.AdminAPI.AccountView alias Pleroma.Web.CommonAPI import Pleroma.Factory @@ -581,11 +582,19 @@ test "returns map with Flag object" do %{} ) + note_obj = %{ + "type" => "Note", + "id" => activity_ap_id, + "content" => content, + "published" => activity.object.data["published"], + "actor" => AccountView.render("show.json", %{user: target_account}) + } + assert %{ "type" => "Flag", "content" => ^content, "context" => ^context, - "object" => [^target_ap_id, ^activity_ap_id], + "object" => [^target_ap_id, ^note_obj], "state" => "open" } = res end diff --git a/test/web/common_api/common_api_test.exs b/test/web/common_api/common_api_test.exs index 83df44c36..709aa4dbe 100644 --- a/test/web/common_api/common_api_test.exs +++ b/test/web/common_api/common_api_test.exs @@ -10,6 +10,7 @@ defmodule Pleroma.Web.CommonAPITest do alias Pleroma.User alias Pleroma.Web.ActivityPub.ActivityPub alias Pleroma.Web.ActivityPub.Visibility + alias Pleroma.Web.AdminAPI.AccountView alias Pleroma.Web.CommonAPI import Pleroma.Factory @@ -385,6 +386,14 @@ test "creates a report" do "status_ids" => [activity.id] } + note_obj = %{ + "type" => "Note", + "id" => activity_ap_id, + "content" => "foobar", + "published" => activity.object.data["published"], + "actor" => AccountView.render("show.json", %{user: target_user}) + } + assert {:ok, flag_activity} = CommonAPI.report(reporter, report_data) assert %Activity{ @@ -392,7 +401,7 @@ test "creates a report" do data: %{ "type" => "Flag", "content" => ^comment, - "object" => [^target_ap_id, ^activity_ap_id], + "object" => [^target_ap_id, ^note_obj], "state" => "open" } } = flag_activity From 8eff05d4c62c4d3300fee173cad84f75a0aafb4d Mon Sep 17 00:00:00 2001 From: Maxim Filippov Date: Sun, 27 Oct 2019 16:05:32 +0300 Subject: [PATCH 030/154] Strip status data from Flag (when federating or closing/resolving report) --- CHANGELOG.md | 1 + lib/pleroma/web/activity_pub/activity_pub.ex | 3 +- lib/pleroma/web/activity_pub/utils.ex | 23 ++++ test/web/activity_pub/activity_pub_test.exs | 122 +++++++++++++------ test/web/common_api/common_api_test.exs | 5 + 5 files changed, 119 insertions(+), 35 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e3ccfa4ea..4744567d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - MRF (Simple Policy): Also use `:accept`/`:reject` on the actors rather than only their activities - OStatus: Extract RSS functionality - Mastodon API: Add `pleroma.direct_conversation_id` to the status endpoint (`GET /api/v1/statuses/:id`) +- Store status data inside Flag activity ### Fixed - Mastodon API: Fix private and direct statuses not being filtered out from the public timeline for an authenticated user (`GET /api/v1/timelines/public`) diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex index 1d34c4d7e..4cdf4876e 100644 --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@ -491,7 +491,8 @@ def flag( with flag_data <- make_flag_data(params, additional), {:ok, activity} <- insert(flag_data, local), - :ok <- maybe_federate(activity) do + {:ok, stripped_activity} <- strip_report_status_data(activity), + :ok <- maybe_federate(stripped_activity) do Enum.each(User.all_superusers(), fn superuser -> superuser |> Pleroma.Emails.AdminEmail.report(actor, account, statuses, content) diff --git a/lib/pleroma/web/activity_pub/utils.ex b/lib/pleroma/web/activity_pub/utils.ex index c58ee7482..520cc1b0c 100644 --- a/lib/pleroma/web/activity_pub/utils.ex +++ b/lib/pleroma/web/activity_pub/utils.ex @@ -22,6 +22,7 @@ defmodule Pleroma.Web.ActivityPub.Utils do require Pleroma.Constants @supported_object_types ["Article", "Note", "Video", "Page", "Question", "Answer", "Audio"] + @strip_status_report_states ~w(closed resolved) @supported_report_states ~w(open closed resolved) @valid_visibilities ~w(public unlisted private direct) @@ -673,6 +674,20 @@ def fetch_ordered_collection(from, pages_left, acc \\ []) do #### Report-related helpers + def update_report_state(%Activity{} = activity, state) + when state in @strip_status_report_states do + {:ok, stripped_activity} = strip_report_status_data(activity) + + new_data = + activity.data + |> Map.put("state", state) + |> Map.put("object", stripped_activity.data["object"]) + + activity + |> Changeset.change(data: new_data) + |> Repo.update() + end + def update_report_state(%Activity{} = activity, state) when state in @supported_report_states do new_data = Map.put(activity.data, "state", state) @@ -683,6 +698,14 @@ def update_report_state(%Activity{} = activity, state) when state in @supported_ def update_report_state(_, _), do: {:error, "Unsupported state"} + def strip_report_status_data(activity) do + [actor | reported_activities] = activity.data["object"] + stripped_activities = Enum.map(reported_activities, & &1["id"]) + new_data = put_in(activity.data, ["object"], [actor | stripped_activities]) + + {:ok, %{activity | data: new_data}} + end + def update_activity_visibility(activity, visibility) when visibility in @valid_visibilities do [to, cc, recipients] = activity diff --git a/test/web/activity_pub/activity_pub_test.exs b/test/web/activity_pub/activity_pub_test.exs index cbd81b698..ddc6493c0 100644 --- a/test/web/activity_pub/activity_pub_test.exs +++ b/test/web/activity_pub/activity_pub_test.exs @@ -1255,45 +1255,99 @@ test "returned pinned statuses" do assert 3 = length(activities) end - test "it can create a Flag activity" do - reporter = insert(:user) - target_account = insert(:user) - {:ok, activity} = CommonAPI.post(target_account, %{"status" => "foobar"}) - context = Utils.generate_context_id() - content = "foobar" + describe "flag/1" do + setup do + reporter = insert(:user) + target_account = insert(:user) + content = "foobar" + {:ok, activity} = CommonAPI.post(target_account, %{"status" => content}) + context = Utils.generate_context_id() - reporter_ap_id = reporter.ap_id - target_ap_id = target_account.ap_id - activity_ap_id = activity.data["id"] + reporter_ap_id = reporter.ap_id + target_ap_id = target_account.ap_id + activity_ap_id = activity.data["id"] - activity_with_object = Activity.get_by_ap_id_with_object(activity_ap_id) + activity_with_object = Activity.get_by_ap_id_with_object(activity_ap_id) - assert {:ok, activity} = - ActivityPub.flag(%{ - actor: reporter, - context: context, - account: target_account, - statuses: [activity], - content: content - }) + {:ok, + %{ + reporter: reporter, + context: context, + target_account: target_account, + reported_activity: activity, + content: content, + activity_ap_id: activity_ap_id, + activity_with_object: activity_with_object, + reporter_ap_id: reporter_ap_id, + target_ap_id: target_ap_id + }} + end - note_obj = %{ - "type" => "Note", - "id" => activity_ap_id, - "content" => content, - "published" => activity_with_object.object.data["published"], - "actor" => AccountView.render("show.json", %{user: target_account}) - } + test "it can create a Flag activity", + %{ + reporter: reporter, + context: context, + target_account: target_account, + reported_activity: reported_activity, + content: content, + activity_ap_id: activity_ap_id, + activity_with_object: activity_with_object, + reporter_ap_id: reporter_ap_id, + target_ap_id: target_ap_id + } do + assert {:ok, activity} = + ActivityPub.flag(%{ + actor: reporter, + context: context, + account: target_account, + statuses: [reported_activity], + content: content + }) - assert %Activity{ - actor: ^reporter_ap_id, - data: %{ - "type" => "Flag", - "content" => ^content, - "context" => ^context, - "object" => [^target_ap_id, ^note_obj] - } - } = activity + note_obj = %{ + "type" => "Note", + "id" => activity_ap_id, + "content" => content, + "published" => activity_with_object.object.data["published"], + "actor" => AccountView.render("show.json", %{user: target_account}) + } + + assert %Activity{ + actor: ^reporter_ap_id, + data: %{ + "type" => "Flag", + "content" => ^content, + "context" => ^context, + "object" => [^target_ap_id, ^note_obj] + } + } = activity + end + + test_with_mock "strips status data from Flag, before federating it", + %{ + reporter: reporter, + context: context, + target_account: target_account, + reported_activity: reported_activity, + content: content + }, + Utils, + [:passthrough], + [] do + {:ok, activity} = + ActivityPub.flag(%{ + actor: reporter, + context: context, + account: target_account, + statuses: [reported_activity], + content: content + }) + + new_data = + put_in(activity.data, ["object"], [target_account.ap_id, reported_activity.data["id"]]) + + assert_called(Utils.maybe_federate(%{activity | data: new_data})) + end end test "fetch_activities/2 returns activities addressed to a list " do diff --git a/test/web/common_api/common_api_test.exs b/test/web/common_api/common_api_test.exs index 709aa4dbe..d69ed38a7 100644 --- a/test/web/common_api/common_api_test.exs +++ b/test/web/common_api/common_api_test.exs @@ -421,6 +421,11 @@ test "updates report state" do {:ok, report} = CommonAPI.update_report_state(report_id, "resolved") assert report.data["state"] == "resolved" + + [reported_user, activity_id] = report.data["object"] + + assert reported_user == target_user.ap_id + assert activity_id == activity.data["id"] end test "does not update report state when state is unsupported" do From 8282b6ac3d977e2e427c42ef3669d547170cc27d Mon Sep 17 00:00:00 2001 From: Maxim Filippov Date: Sun, 27 Oct 2019 16:17:37 +0300 Subject: [PATCH 031/154] Make sure incoming flags are updated with status data --- test/web/activity_pub/transmogrifier_test.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/web/activity_pub/transmogrifier_test.exs b/test/web/activity_pub/transmogrifier_test.exs index 1069ade02..4df3024a6 100644 --- a/test/web/activity_pub/transmogrifier_test.exs +++ b/test/web/activity_pub/transmogrifier_test.exs @@ -1102,7 +1102,7 @@ test "it accepts Flag activities" do message = %{ "@context" => "https://www.w3.org/ns/activitystreams", "cc" => [user.ap_id], - "object" => [user.ap_id, activity], + "object" => [user.ap_id, activity.data["id"]], "type" => "Flag", "content" => "blocked AND reported!!!", "actor" => other_user.ap_id From d56bc622755ea0a858bf086bc1f525c1752e4db8 Mon Sep 17 00:00:00 2001 From: Maxim Filippov Date: Sun, 27 Oct 2019 16:33:58 +0300 Subject: [PATCH 032/154] Fix report parsing --- lib/pleroma/web/admin_api/report.ex | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/pleroma/web/admin_api/report.ex b/lib/pleroma/web/admin_api/report.ex index ccd56e15e..9c3468570 100644 --- a/lib/pleroma/web/admin_api/report.ex +++ b/lib/pleroma/web/admin_api/report.ex @@ -13,8 +13,9 @@ def extract_report_info( account = User.get_cached_by_ap_id(account_ap_id) statuses = - Enum.map(status_ap_ids, fn act -> - Activity.get_by_ap_id_with_object(act["id"]) + Enum.map(status_ap_ids, fn + act when is_map(act) -> Activity.get_by_ap_id_with_object(act["id"]) + act when is_binary(act) -> Activity.get_by_ap_id_with_object(act) end) %{report: report, user: user, account: account, statuses: statuses} From 0be9cb086b070858b041cd15ee149d1323952aab Mon Sep 17 00:00:00 2001 From: Roman Chvanikov Date: Sun, 27 Oct 2019 19:29:35 +0300 Subject: [PATCH 033/154] Add migration --- ...91027143434_add_defaults_to_all_tables.exs | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 priv/repo/migrations/20191027143434_add_defaults_to_all_tables.exs diff --git a/priv/repo/migrations/20191027143434_add_defaults_to_all_tables.exs b/priv/repo/migrations/20191027143434_add_defaults_to_all_tables.exs new file mode 100644 index 000000000..ab60f1313 --- /dev/null +++ b/priv/repo/migrations/20191027143434_add_defaults_to_all_tables.exs @@ -0,0 +1,52 @@ +defmodule Pleroma.Repo.Migrations.AddDefaultsToAllTables do + use Ecto.Migration + + def up do + execute("ALTER TABLE activities + ALTER COLUMN recipients SET DEFAULT ARRAY[]::character varying[]") + + execute("ALTER TABLE filters + ALTER COLUMN whole_word SET DEFAULT true") + + execute("ALTER TABLE push_subscriptions + ALTER COLUMN data SET DEFAULT '{}'::jsonb") + + execute(~s(ALTER TABLE users + ALTER COLUMN following SET DEFAULT ARRAY[]::character varying[], + ALTER COLUMN tags SET DEFAULT ARRAY[]::character varying[], + ALTER COLUMN notification_settings SET DEFAULT + '{"followers": true, "follows": true, "non_follows": true, "non_followers": true}'::jsonb)) + + # irreversible updates + + execute( + "UPDATE activities SET recipients = ARRAY[]::character varying[] WHERE recipients IS NULL" + ) + + execute("UPDATE filters SET whole_word = true WHERE whole_word IS NULL") + + execute("UPDATE push_subscriptions SET data = '{}'::jsonb WHERE data IS NULL") + + execute("UPDATE users SET following = ARRAY[]::character varying[] WHERE following IS NULL") + execute("UPDATE users SET tags = ARRAY[]::character varying[] WHERE tags IS NULL") + execute(~s(UPDATE users SET notification_settings = + '{"followers": true, "follows": true, "non_follows": true, "non_followers": true}'::jsonb + WHERE notification_settings = '{}'::jsonb)) + end + + def down do + execute("ALTER TABLE activities + ALTER COLUMN recipients DROP DEFAULT") + + execute("ALTER TABLE filters + ALTER COLUMN whole_word DROP DEFAULT") + + execute("ALTER TABLE push_subscriptions + ALTER COLUMN data DROP DEFAULT") + + execute("ALTER TABLE users + ALTER COLUMN following DROP DEFAULT, + ALTER COLUMN tags DROP DEFAULT, + ALTER COLUMN notification_settings SET DEFAULT '{}'::jsonb") + end +end From 4b0893631f2d9f157c200f2787fe5154dc0b811e Mon Sep 17 00:00:00 2001 From: Roman Chvanikov Date: Mon, 28 Oct 2019 19:16:19 +0300 Subject: [PATCH 034/154] Complete defaults --- ...91027143434_add_defaults_to_all_tables.exs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/priv/repo/migrations/20191027143434_add_defaults_to_all_tables.exs b/priv/repo/migrations/20191027143434_add_defaults_to_all_tables.exs index ab60f1313..0d2794ad3 100644 --- a/priv/repo/migrations/20191027143434_add_defaults_to_all_tables.exs +++ b/priv/repo/migrations/20191027143434_add_defaults_to_all_tables.exs @@ -27,6 +27,25 @@ def up do execute("UPDATE push_subscriptions SET data = '{}'::jsonb WHERE data IS NULL") + execute("UPDATE users SET source_data = '{}'::jsonb where source_data IS NULL") + execute("UPDATE users SET note_count = 0 where note_count IS NULL") + execute("UPDATE users SET background = '{}'::jsonb where background IS NULL") + execute("UPDATE users SET follower_count = 0 where follower_count IS NULL") + + execute( + "UPDATE users SET unread_conversation_count = 0 where unread_conversation_count IS NULL" + ) + + execute( + ~s(UPDATE users SET email_notifications = '{"digest": false}'::jsonb where email_notifications IS NULL) + ) + + execute("UPDATE users SET default_scope = 'public' where default_scope IS NULL") + + execute( + "UPDATE users SET pleroma_settings_store = '{}'::jsonb where pleroma_settings_store IS NULL" + ) + execute("UPDATE users SET following = ARRAY[]::character varying[] WHERE following IS NULL") execute("UPDATE users SET tags = ARRAY[]::character varying[] WHERE tags IS NULL") execute(~s(UPDATE users SET notification_settings = From 435d220700c694f1312bf213d0591054a309489a Mon Sep 17 00:00:00 2001 From: Roman Chvanikov Date: Mon, 28 Oct 2019 19:17:50 +0300 Subject: [PATCH 035/154] Move setDefaultsToTables to past to run before notNull migrations --- ...all_tables.exs => 20191025143434_add_defaults_to_tables.exs} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename priv/repo/migrations/{20191027143434_add_defaults_to_all_tables.exs => 20191025143434_add_defaults_to_tables.exs} (97%) diff --git a/priv/repo/migrations/20191027143434_add_defaults_to_all_tables.exs b/priv/repo/migrations/20191025143434_add_defaults_to_tables.exs similarity index 97% rename from priv/repo/migrations/20191027143434_add_defaults_to_all_tables.exs rename to priv/repo/migrations/20191025143434_add_defaults_to_tables.exs index 0d2794ad3..d16ab19f9 100644 --- a/priv/repo/migrations/20191027143434_add_defaults_to_all_tables.exs +++ b/priv/repo/migrations/20191025143434_add_defaults_to_tables.exs @@ -1,4 +1,4 @@ -defmodule Pleroma.Repo.Migrations.AddDefaultsToAllTables do +defmodule Pleroma.Repo.Migrations.AddDefaultsToTables do use Ecto.Migration def up do From 56e42602b0037f92d86fcbbbafa798a323afc12d Mon Sep 17 00:00:00 2001 From: stwf Date: Mon, 28 Oct 2019 12:51:58 -0400 Subject: [PATCH 036/154] capture where errors are expected --- test/web/activity_pub/transmogrifier_test.exs | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/test/web/activity_pub/transmogrifier_test.exs b/test/web/activity_pub/transmogrifier_test.exs index 2f25c40d2..7c3c4bb9b 100644 --- a/test/web/activity_pub/transmogrifier_test.exs +++ b/test/web/activity_pub/transmogrifier_test.exs @@ -746,7 +746,10 @@ test "it fails for incoming user deletes with spoofed origin" do |> Poison.decode!() |> Map.put("actor", ap_id) - assert :error == Transmogrifier.handle_incoming(data) + assert capture_log(fn -> + assert :error == Transmogrifier.handle_incoming(data) + end) =~ "Object containment failed" + assert User.get_cached_by_ap_id(ap_id) end @@ -1409,7 +1412,9 @@ test "it rejects activities which reference objects with bogus origins" do "type" => "Announce" } - :error = Transmogrifier.handle_incoming(data) + assert capture_log(fn -> + :error = Transmogrifier.handle_incoming(data) + end) =~ "Object containment failed" end test "it rejects activities which reference objects that have an incorrect attribution (variant 1)" do @@ -1422,7 +1427,9 @@ test "it rejects activities which reference objects that have an incorrect attri "type" => "Announce" } - :error = Transmogrifier.handle_incoming(data) + assert capture_log(fn -> + :error = Transmogrifier.handle_incoming(data) + end) =~ "Object containment failed" end test "it rejects activities which reference objects that have an incorrect attribution (variant 2)" do @@ -1435,7 +1442,9 @@ test "it rejects activities which reference objects that have an incorrect attri "type" => "Announce" } - :error = Transmogrifier.handle_incoming(data) + assert capture_log(fn -> + :error = Transmogrifier.handle_incoming(data) + end) =~ "Object containment failed" end end @@ -1738,7 +1747,9 @@ test "retunrs not modified object" do describe "get_obj_helper/2" do test "returns nil when cannot normalize object" do - refute Transmogrifier.get_obj_helper("test-obj-id") + assert capture_log(fn -> + refute Transmogrifier.get_obj_helper("test-obj-id") + end) =~ "Unsupported URI scheme" end test "returns {:ok, %Object{}} for success case" do From 05d111b622c7496260effd298163e9ca2aa59c3d Mon Sep 17 00:00:00 2001 From: rinpatch Date: Tue, 29 Oct 2019 01:15:28 +0300 Subject: [PATCH 037/154] Use the default scrubber before mediaproxy transformation --- config/config.exs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/config.exs b/config/config.exs index a69d41d17..e2b00bda1 100644 --- a/config/config.exs +++ b/config/config.exs @@ -284,8 +284,8 @@ allow_tables: false, allow_fonts: false, scrub_policy: [ - Pleroma.HTML.Transform.MediaProxy, - Pleroma.HTML.Scrubber.Default + Pleroma.HTML.Scrubber.Default, + Pleroma.HTML.Transform.MediaProxy ] config :pleroma, :frontend_configurations, From 9434e151a9f08067bf324ef027d857b67b0a96cb Mon Sep 17 00:00:00 2001 From: rinpatch Date: Tue, 29 Oct 2019 01:16:22 +0300 Subject: [PATCH 038/154] Blacklist myhtmlex nodes from swarm --- config/config.exs | 1 + 1 file changed, 1 insertion(+) diff --git a/config/config.exs b/config/config.exs index e2b00bda1..81d50cdee 100644 --- a/config/config.exs +++ b/config/config.exs @@ -603,6 +603,7 @@ activity_pub: nil, activity_pub_question: 30_000 +config :swarm, node_blacklist: [~r/myhtmlex_.*$/] # Import environment specific config. This must remain at the bottom # of this file so it overrides the configuration defined above. import_config "#{Mix.env()}.exs" From 2453928b57d3dbe60a5f6a4a85f2f03d3192108e Mon Sep 17 00:00:00 2001 From: rinpatch Date: Tue, 29 Oct 2019 01:16:57 +0300 Subject: [PATCH 039/154] Ensure myhtmlex is started before swarm Otherwise swarm is going to attempt resizing the cluster and timeout --- mix.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mix.exs b/mix.exs index dcb9d9ea8..705d56f0e 100644 --- a/mix.exs +++ b/mix.exs @@ -63,7 +63,7 @@ def copy_nginx_config(%{path: target_path} = release) do def application do [ mod: {Pleroma.Application, []}, - extra_applications: [:logger, :runtime_tools, :comeonin, :quack], + extra_applications: [:logger, :runtime_tools, :comeonin, :quack, :myhtmlex, :swarm], included_applications: [:ex_syslogger] ] end From 08f68370659597d6bc428e425925bcb9516d5706 Mon Sep 17 00:00:00 2001 From: rinpatch Date: Tue, 29 Oct 2019 01:18:08 +0300 Subject: [PATCH 040/154] Switch from HtmlSanitizeEx to FastSanitize --- lib/pleroma/html.ex | 129 +++++++++--------- test/emoji/formatter_test.exs | 2 +- test/html_test.exs | 44 +++--- .../mrf/normalize_markup_test.exs | 10 +- test/web/common_api/common_api_test.exs | 4 +- 5 files changed, 95 insertions(+), 94 deletions(-) diff --git a/lib/pleroma/html.ex b/lib/pleroma/html.ex index 937bafed5..fd0495049 100644 --- a/lib/pleroma/html.ex +++ b/lib/pleroma/html.ex @@ -3,7 +3,6 @@ # SPDX-License-Identifier: AGPL-3.0-only 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 @@ -24,9 +23,13 @@ def filter_tags(html, scrubbers) when is_list(scrubbers) do end) end - def filter_tags(html, scrubber), do: Scrubber.scrub(html, scrubber) + def filter_tags(html, scrubber) do + {:ok, content} = FastSanitize.Sanitizer.scrub(html, scrubber) + content + end + def filter_tags(html), do: filter_tags(html, nil) - def strip_tags(html), do: Scrubber.scrub(html, Scrubber.StripTags) + def strip_tags(html), do: filter_tags(html, FastSanitize.Sanitizer.StripTags) def get_cached_scrubbed_html_for_activity( content, @@ -36,7 +39,6 @@ def get_cached_scrubbed_html_for_activity( callback \\ fn x -> x end ) do key = "#{key}#{generate_scrubber_signature(scrubbers)}|#{activity.id}" - Cachex.fetch!(:scrubber_cache, key, fn _key -> object = Pleroma.Object.normalize(activity) ensure_scrubbed_html(content, scrubbers, object.data["fake"] || false, callback) @@ -46,7 +48,7 @@ def get_cached_scrubbed_html_for_activity( def get_cached_stripped_html_for_activity(content, activity, key) do get_cached_scrubbed_html_for_activity( content, - HtmlSanitizeEx.Scrubber.StripTags, + FastSanitize.Sanitizer.StripTags, activity, key, &HtmlEntities.decode/1 @@ -109,13 +111,12 @@ defmodule Pleroma.HTML.Scrubber.TwitterText do require HtmlSanitizeEx.Scrubber.Meta alias HtmlSanitizeEx.Scrubber.Meta - Meta.remove_cdata_sections_before_scrub() Meta.strip_comments() # links - Meta.allow_tag_with_uri_attributes("a", ["href", "data-user", "data-tag"], @valid_schemes) + Meta.allow_tag_with_uri_attributes(:a, ["href", "data-user", "data-tag"], @valid_schemes) - Meta.allow_tag_with_this_attribute_values("a", "class", [ + Meta.allow_tag_with_this_attribute_values(:a, "class", [ "hashtag", "u-url", "mention", @@ -123,29 +124,29 @@ defmodule Pleroma.HTML.Scrubber.TwitterText do "mention u-url" ]) - Meta.allow_tag_with_this_attribute_values("a", "rel", [ + Meta.allow_tag_with_this_attribute_values(:a, "rel", [ "tag", "nofollow", "noopener", "noreferrer" ]) - Meta.allow_tag_with_these_attributes("a", ["name", "title"]) + Meta.allow_tag_with_these_attributes(:a, ["name", "title"]) # paragraphs and linebreaks - Meta.allow_tag_with_these_attributes("br", []) - Meta.allow_tag_with_these_attributes("p", []) + Meta.allow_tag_with_these_attributes(:br, []) + Meta.allow_tag_with_these_attributes(:p, []) # microformats - Meta.allow_tag_with_this_attribute_values("span", "class", ["h-card"]) - Meta.allow_tag_with_these_attributes("span", []) + Meta.allow_tag_with_this_attribute_values(:span, "class", ["h-card"]) + Meta.allow_tag_with_these_attributes(:span, []) # allow inline images for custom emoji if Pleroma.Config.get([:markup, :allow_inline_images]) do # restrict img tags to http/https only, because of MediaProxy. - Meta.allow_tag_with_uri_attributes("img", ["src"], ["http", "https"]) + Meta.allow_tag_with_uri_attributes(:img, ["src"], ["http", "https"]) - Meta.allow_tag_with_these_attributes("img", [ + Meta.allow_tag_with_these_attributes(:img, [ "width", "height", "class", @@ -160,19 +161,19 @@ defmodule Pleroma.HTML.Scrubber.TwitterText do defmodule Pleroma.HTML.Scrubber.Default do @doc "The default HTML scrubbing policy: no " - require HtmlSanitizeEx.Scrubber.Meta - alias HtmlSanitizeEx.Scrubber.Meta + require FastSanitize.Sanitizer.Meta + alias FastSanitize.Sanitizer.Meta # credo:disable-for-previous-line # No idea how to fix this one… @valid_schemes Pleroma.Config.get([:uri_schemes, :valid_schemes], []) - Meta.remove_cdata_sections_before_scrub() +# Meta.remove_cdata_sections_before_scrub() Meta.strip_comments() - Meta.allow_tag_with_uri_attributes("a", ["href", "data-user", "data-tag"], @valid_schemes) + Meta.allow_tag_with_uri_attributes(:a, ["href", "data-user", "data-tag"], @valid_schemes) - Meta.allow_tag_with_this_attribute_values("a", "class", [ + Meta.allow_tag_with_this_attribute_values(:a, "class", [ "hashtag", "u-url", "mention", @@ -180,7 +181,7 @@ defmodule Pleroma.HTML.Scrubber.Default do "mention u-url" ]) - Meta.allow_tag_with_this_attribute_values("a", "rel", [ + Meta.allow_tag_with_this_attribute_values(:a, "rel", [ "tag", "nofollow", "noopener", @@ -188,37 +189,37 @@ defmodule Pleroma.HTML.Scrubber.Default do "ugc" ]) - Meta.allow_tag_with_these_attributes("a", ["name", "title"]) + Meta.allow_tag_with_these_attributes(:a, ["name", "title"]) - Meta.allow_tag_with_these_attributes("abbr", ["title"]) + Meta.allow_tag_with_these_attributes(:abbr, ["title"]) - Meta.allow_tag_with_these_attributes("b", []) - Meta.allow_tag_with_these_attributes("blockquote", []) - Meta.allow_tag_with_these_attributes("br", []) - Meta.allow_tag_with_these_attributes("code", []) - Meta.allow_tag_with_these_attributes("del", []) - Meta.allow_tag_with_these_attributes("em", []) - Meta.allow_tag_with_these_attributes("i", []) - Meta.allow_tag_with_these_attributes("li", []) - Meta.allow_tag_with_these_attributes("ol", []) - Meta.allow_tag_with_these_attributes("p", []) - Meta.allow_tag_with_these_attributes("pre", []) - Meta.allow_tag_with_these_attributes("strong", []) - Meta.allow_tag_with_these_attributes("sub", []) - Meta.allow_tag_with_these_attributes("sup", []) - Meta.allow_tag_with_these_attributes("u", []) - Meta.allow_tag_with_these_attributes("ul", []) + Meta.allow_tag_with_these_attributes(:b, []) + Meta.allow_tag_with_these_attributes(:blockquote, []) + Meta.allow_tag_with_these_attributes(:br, []) + Meta.allow_tag_with_these_attributes(:code, []) + Meta.allow_tag_with_these_attributes(:del, []) + Meta.allow_tag_with_these_attributes(:em, []) + Meta.allow_tag_with_these_attributes(:i, []) + Meta.allow_tag_with_these_attributes(:li, []) + Meta.allow_tag_with_these_attributes(:ol, []) + Meta.allow_tag_with_these_attributes(:p, []) + Meta.allow_tag_with_these_attributes(:pre, []) + Meta.allow_tag_with_these_attributes(:strong, []) + Meta.allow_tag_with_these_attributes(:sub, []) + Meta.allow_tag_with_these_attributes(:sup, []) + Meta.allow_tag_with_these_attributes(:u, []) + Meta.allow_tag_with_these_attributes(:ul, []) - Meta.allow_tag_with_this_attribute_values("span", "class", ["h-card"]) - Meta.allow_tag_with_these_attributes("span", []) + Meta.allow_tag_with_this_attribute_values(:span, "class", ["h-card"]) + Meta.allow_tag_with_these_attributes(:span, []) @allow_inline_images Pleroma.Config.get([:markup, :allow_inline_images]) if @allow_inline_images do # restrict img tags to http/https only, because of MediaProxy. - Meta.allow_tag_with_uri_attributes("img", ["src"], ["http", "https"]) + Meta.allow_tag_with_uri_attributes(:img, ["src"], ["http", "https"]) - Meta.allow_tag_with_these_attributes("img", [ + Meta.allow_tag_with_these_attributes(:img, [ "width", "height", "class", @@ -228,24 +229,24 @@ defmodule Pleroma.HTML.Scrubber.Default do end if Pleroma.Config.get([:markup, :allow_tables]) do - Meta.allow_tag_with_these_attributes("table", []) - Meta.allow_tag_with_these_attributes("tbody", []) - Meta.allow_tag_with_these_attributes("td", []) - Meta.allow_tag_with_these_attributes("th", []) - Meta.allow_tag_with_these_attributes("thead", []) - Meta.allow_tag_with_these_attributes("tr", []) + Meta.allow_tag_with_these_attributes(:table, []) + Meta.allow_tag_with_these_attributes(:tbody, []) + Meta.allow_tag_with_these_attributes(:td, []) + Meta.allow_tag_with_these_attributes(:th, []) + Meta.allow_tag_with_these_attributes(:thead, []) + Meta.allow_tag_with_these_attributes(:tr, []) end if Pleroma.Config.get([:markup, :allow_headings]) do - Meta.allow_tag_with_these_attributes("h1", []) - Meta.allow_tag_with_these_attributes("h2", []) - Meta.allow_tag_with_these_attributes("h3", []) - Meta.allow_tag_with_these_attributes("h4", []) - Meta.allow_tag_with_these_attributes("h5", []) + Meta.allow_tag_with_these_attributes(:h1, []) + Meta.allow_tag_with_these_attributes(:h2, []) + Meta.allow_tag_with_these_attributes(:h3, []) + Meta.allow_tag_with_these_attributes(:h4, []) + Meta.allow_tag_with_these_attributes(:h5, []) end if Pleroma.Config.get([:markup, :allow_fonts]) do - Meta.allow_tag_with_these_attributes("font", ["face"]) + Meta.allow_tag_with_these_attributes(:font, ["face"]) end Meta.strip_everything_not_covered() @@ -258,7 +259,7 @@ defmodule Pleroma.HTML.Transform.MediaProxy do def before_scrub(html), do: html - def scrub_attribute("img", {"src", "http" <> target}) do + def scrub_attribute(:img, {"src", "http" <> target}) do media_url = ("http" <> target) |> MediaProxy.url() @@ -268,16 +269,16 @@ def scrub_attribute("img", {"src", "http" <> target}) do def scrub_attribute(_tag, attribute), do: attribute - def scrub({"img", attributes, children}) do + def scrub({:img, attributes, children}) do attributes = attributes - |> Enum.map(fn attr -> scrub_attribute("img", attr) end) + |> Enum.map(fn attr -> scrub_attribute(:img, attr) end) |> Enum.reject(&is_nil(&1)) - {"img", attributes, children} + {:img, attributes, children} end - def scrub({:comment, _children}), do: "" + def scrub({:comment, _text, _children}), do: "" def scrub({tag, attributes, children}), do: {tag, attributes, children} def scrub({_tag, children}), do: children @@ -298,9 +299,9 @@ defmodule Pleroma.HTML.Scrubber.LinksOnly do Meta.strip_comments() # links - Meta.allow_tag_with_uri_attributes("a", ["href"], @valid_schemes) + Meta.allow_tag_with_uri_attributes(:a, ["href"], @valid_schemes) - Meta.allow_tag_with_this_attribute_values("a", "rel", [ + Meta.allow_tag_with_this_attribute_values(:a, "rel", [ "tag", "nofollow", "noopener", @@ -309,6 +310,6 @@ defmodule Pleroma.HTML.Scrubber.LinksOnly do "ugc" ]) - Meta.allow_tag_with_these_attributes("a", ["name", "title"]) + Meta.allow_tag_with_these_attributes(:a, ["name", "title"]) Meta.strip_everything_not_covered() end diff --git a/test/emoji/formatter_test.exs b/test/emoji/formatter_test.exs index 6d25fc453..3e37ae3f0 100644 --- a/test/emoji/formatter_test.exs +++ b/test/emoji/formatter_test.exs @@ -12,7 +12,7 @@ test "it adds cool emoji" do text = "I love :firefox:" expected_result = - "I love \"firefox\"" + "I love \"firefox\"" assert Formatter.emojify(text) == expected_result end diff --git a/test/html_test.exs b/test/html_test.exs index 306ad3b3b..f0869534c 100644 --- a/test/html_test.exs +++ b/test/html_test.exs @@ -21,31 +21,31 @@ defmodule Pleroma.HTMLTest do """ @html_onerror_sample """ - + """ @html_span_class_sample """ - hi + hi """ @html_span_microformats_sample """ - @foo + @foo """ @html_span_invalid_microformats_sample """ - @foo + @foo """ describe "StripTags scrubber" do test "works as expected" do expected = """ - this is in bold + this is in bold this is a paragraph this is a linebreak - this is a link with allowed "rel" attribute: example.com - this is a link with not allowed "rel" attribute: example.com + this is a link with allowed "rel" attribute: example.com + this is a link with not allowed "rel" attribute: example.com this is an image: - alert('hacked') + alert('hacked') """ assert expected == HTML.strip_tags(@html_sample) @@ -61,13 +61,13 @@ test "does not allow attribute-based XSS" do describe "TwitterText scrubber" do test "normalizes HTML as expected" do expected = """ - this is in bold + this is in bold

this is a paragraph

- this is a linebreak
- this is a link with allowed "rel" attribute: - this is a link with not allowed "rel" attribute: example.com - this is an image:
- alert('hacked') + this is a linebreak
+ this is a link with allowed "rel" attribute: + this is a link with not allowed "rel" attribute: example.com + this is an image:
+ alert('hacked') """ assert expected == HTML.filter_tags(@html_sample, Pleroma.HTML.Scrubber.TwitterText) @@ -75,7 +75,7 @@ test "normalizes HTML as expected" do test "does not allow attribute-based XSS" do expected = """ - + """ assert expected == HTML.filter_tags(@html_onerror_sample, Pleroma.HTML.Scrubber.TwitterText) @@ -115,13 +115,13 @@ test "filters invalid microformats markup" do describe "default scrubber" do test "normalizes HTML as expected" do expected = """ - this is in bold + this is in bold

this is a paragraph

- this is a linebreak
- this is a link with allowed "rel" attribute: - this is a link with not allowed "rel" attribute: example.com - this is an image:
- alert('hacked') + this is a linebreak
+ this is a link with allowed "rel" attribute: + this is a link with not allowed "rel" attribute: example.com + this is an image:
+ alert('hacked') """ assert expected == HTML.filter_tags(@html_sample, Pleroma.HTML.Scrubber.Default) @@ -129,7 +129,7 @@ test "normalizes HTML as expected" do test "does not allow attribute-based XSS" do expected = """ - + """ assert expected == HTML.filter_tags(@html_onerror_sample, Pleroma.HTML.Scrubber.Default) diff --git a/test/web/activity_pub/mrf/normalize_markup_test.exs b/test/web/activity_pub/mrf/normalize_markup_test.exs index 3916a1f35..0207be56b 100644 --- a/test/web/activity_pub/mrf/normalize_markup_test.exs +++ b/test/web/activity_pub/mrf/normalize_markup_test.exs @@ -20,11 +20,11 @@ test "it filter html tags" do expected = """ this is in bold

this is a paragraph

- this is a linebreak
- this is a link with allowed "rel" attribute: - this is a link with not allowed "rel" attribute: example.com - this is an image:
- alert('hacked') + this is a linebreak
+ this is a link with allowed "rel" attribute: + this is a link with not allowed "rel" attribute: example.com + this is an image:
+ alert('hacked') """ message = %{"type" => "Create", "object" => %{"content" => @html_sample}} diff --git a/test/web/common_api/common_api_test.exs b/test/web/common_api/common_api_test.exs index 1d2f20617..212b00cbb 100644 --- a/test/web/common_api/common_api_test.exs +++ b/test/web/common_api/common_api_test.exs @@ -140,7 +140,7 @@ test "it filters out obviously bad tags when accepting a post as HTML" do object = Object.normalize(activity) - assert object.data["content"] == "

2hu

alert('xss')" + assert object.data["content"] == "

2hu

alert('xss')" end test "it filters out obviously bad tags when accepting a post as Markdown" do @@ -156,7 +156,7 @@ test "it filters out obviously bad tags when accepting a post as Markdown" do object = Object.normalize(activity) - assert object.data["content"] == "

2hu

alert('xss')" + assert object.data["content"] == "

2hu

alert('xss')" end test "it does not allow replies to direct messages that are not direct messages themselves" do From 9cde3321a3b4ac6a8df16d7e59f169b545afe55f Mon Sep 17 00:00:00 2001 From: rinpatch Date: Tue, 29 Oct 2019 01:21:00 +0300 Subject: [PATCH 041/154] Add fast_sanitize to dependencies --- mix.exs | 1 + mix.lock | 49 ++++++++++++++++++++++++++----------------------- 2 files changed, 27 insertions(+), 23 deletions(-) diff --git a/mix.exs b/mix.exs index 705d56f0e..0e7c6a6f8 100644 --- a/mix.exs +++ b/mix.exs @@ -109,6 +109,7 @@ defp deps do {:pbkdf2_elixir, "~> 0.12.3"}, {:trailing_format_plug, "~> 0.0.7"}, {:html_sanitize_ex, "~> 1.3.0"}, + {:fast_sanitize, git: "https://git.pleroma.social/pleroma/fast_sanitize.git", ref: "2820d841393b3c2f2183d0377f572bf00f513b7c"}, {:html_entities, "~> 0.4"}, {:phoenix_html, "~> 2.10"}, {:calendar, "~> 0.17.4"}, diff --git a/mix.lock b/mix.lock index 5f740638c..18e2572dd 100644 --- a/mix.lock +++ b/mix.lock @@ -13,44 +13,45 @@ "comeonin": {:hex, :comeonin, "4.1.2", "3eb5620fd8e35508991664b4c2b04dd41e52f1620b36957be837c1d7784b7592", [:mix], [{:argon2_elixir, "~> 1.2", [hex: :argon2_elixir, repo: "hexpm", optional: true]}, {:bcrypt_elixir, "~> 0.12.1 or ~> 1.0", [hex: :bcrypt_elixir, repo: "hexpm", optional: true]}, {:pbkdf2_elixir, "~> 0.12", [hex: :pbkdf2_elixir, repo: "hexpm", optional: true]}], "hexpm"}, "connection": {:hex, :connection, "1.0.4", "a1cae72211f0eef17705aaededacac3eb30e6625b04a6117c1b2db6ace7d5976", [:mix], [], "hexpm"}, "cors_plug": {:hex, :cors_plug, "1.5.2", "72df63c87e4f94112f458ce9d25800900cc88608c1078f0e4faddf20933eda6e", [:mix], [{:plug, "~> 1.3 or ~> 1.4 or ~> 1.5", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"}, - "cowboy": {:hex, :cowboy, "2.6.3", "99aa50e94e685557cad82e704457336a453d4abcb77839ad22dbe71f311fcc06", [:rebar3], [{:cowlib, "~> 2.7.3", [hex: :cowlib, repo: "hexpm", optional: false]}, {:ranch, "~> 1.7.1", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm"}, - "cowlib": {:hex, :cowlib, "2.7.3", "a7ffcd0917e6d50b4d5fb28e9e2085a0ceb3c97dea310505f7460ff5ed764ce9", [:rebar3], [], "hexpm"}, + "cowboy": {:hex, :cowboy, "2.7.0", "91ed100138a764355f43316b1d23d7ff6bdb0de4ea618cb5d8677c93a7a2f115", [:rebar3], [{:cowlib, "~> 2.8.0", [hex: :cowlib, repo: "hexpm", optional: false]}, {:ranch, "~> 1.7.1", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm"}, + "cowlib": {:hex, :cowlib, "2.8.0", "fd0ff1787db84ac415b8211573e9a30a3ebe71b5cbff7f720089972b2319c8a4", [:rebar3], [], "hexpm"}, "credo": {:hex, :credo, "0.9.3", "76fa3e9e497ab282e0cf64b98a624aa11da702854c52c82db1bf24e54ab7c97a", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:poison, ">= 0.0.0", [hex: :poison, repo: "hexpm", optional: false]}], "hexpm"}, - "crontab": {:hex, :crontab, "1.1.7", "b9219f0bdc8678b94143655a8f229716c5810c0636a4489f98c0956137e53985", [:mix], [{:ecto, "~> 1.0 or ~> 2.0 or ~> 3.0", [hex: :ecto, repo: "hexpm", optional: true]}], "hexpm"}, + "crontab": {:hex, :crontab, "1.1.8", "2ce0e74777dfcadb28a1debbea707e58b879e6aa0ffbf9c9bb540887bce43617", [:mix], [{:ecto, "~> 1.0 or ~> 2.0 or ~> 3.0", [hex: :ecto, repo: "hexpm", optional: true]}], "hexpm"}, "crypt": {:git, "https://github.com/msantos/crypt", "1f2b58927ab57e72910191a7ebaeff984382a1d3", [ref: "1f2b58927ab57e72910191a7ebaeff984382a1d3"]}, "custom_base": {:hex, :custom_base, "0.2.1", "4a832a42ea0552299d81652aa0b1f775d462175293e99dfbe4d7dbaab785a706", [:mix], [], "hexpm"}, "db_connection": {:hex, :db_connection, "2.1.1", "a51e8a2ee54ef2ae6ec41a668c85787ed40cb8944928c191280fe34c15b76ae5", [:mix], [{:connection, "~> 1.0.2", [hex: :connection, repo: "hexpm", optional: false]}], "hexpm"}, "decimal": {:hex, :decimal, "1.8.0", "ca462e0d885f09a1c5a342dbd7c1dcf27ea63548c65a65e67334f4b61803822e", [:mix], [], "hexpm"}, "deep_merge": {:hex, :deep_merge, "1.0.0", "b4aa1a0d1acac393bdf38b2291af38cb1d4a52806cf7a4906f718e1feb5ee961", [:mix], [], "hexpm"}, - "earmark": {:hex, :earmark, "1.3.6", "ce1d0675e10a5bb46b007549362bd3f5f08908843957687d8484fe7f37466b19", [:mix], [], "hexpm"}, - "ecto": {:hex, :ecto, "3.2.0", "940e2598813f205223d60c78d66e514afe1db5167ed8075510a59e496619cfb5", [:mix], [{:decimal, "~> 1.6", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm"}, + "earmark": {:hex, :earmark, "1.4.2", "3aa0bd23bc4c61cf2f1e5d752d1bb470560a6f8539974f767a38923bb20e1d7f", [:mix], [], "hexpm"}, + "ecto": {:hex, :ecto, "3.2.3", "51274df79862845b388733fddcf6f107d0c8c86e27abe7131fa98f8d30761bda", [:mix], [{:decimal, "~> 1.6", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm"}, "ecto_sql": {:hex, :ecto_sql, "3.2.0", "751cea597e8deb616084894dd75cbabfdbe7255ff01e8c058ca13f0353a3921b", [:mix], [{:db_connection, "~> 2.1", [hex: :db_connection, repo: "hexpm", optional: false]}, {:ecto, "~> 3.2.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:myxql, "~> 0.2.0", [hex: :myxql, repo: "hexpm", optional: true]}, {:postgrex, "~> 0.15.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm"}, "esshd": {:hex, :esshd, "0.1.0", "6f93a2062adb43637edad0ea7357db2702a4b80dd9683482fe00f5134e97f4c1", [:mix], [], "hexpm"}, - "eternal": {:hex, :eternal, "1.2.0", "e2a6b6ce3b8c248f7dc31451aefca57e3bdf0e48d73ae5043229380a67614c41", [:mix], [], "hexpm"}, + "eternal": {:hex, :eternal, "1.2.1", "d5b6b2499ba876c57be2581b5b999ee9bdf861c647401066d3eeed111d096bc4", [:mix], [], "hexpm"}, "ex2ms": {:hex, :ex2ms, "1.5.0", "19e27f9212be9a96093fed8cdfbef0a2b56c21237196d26760f11dfcfae58e97", [:mix], [], "hexpm"}, - "ex_aws": {:hex, :ex_aws, "2.1.0", "b92651527d6c09c479f9013caa9c7331f19cba38a650590d82ebf2c6c16a1d8a", [:mix], [{:configparser_ex, "~> 2.0", [hex: :configparser_ex, repo: "hexpm", optional: true]}, {:hackney, "1.6.3 or 1.6.5 or 1.7.1 or 1.8.6 or ~> 1.9", [hex: :hackney, repo: "hexpm", optional: true]}, {:jsx, "~> 2.8", [hex: :jsx, repo: "hexpm", optional: true]}, {:poison, ">= 1.2.0", [hex: :poison, repo: "hexpm", optional: true]}, {:sweet_xml, "~> 0.6", [hex: :sweet_xml, repo: "hexpm", optional: true]}, {:xml_builder, "~> 0.1.0", [hex: :xml_builder, repo: "hexpm", optional: true]}], "hexpm"}, - "ex_aws_s3": {:hex, :ex_aws_s3, "2.0.1", "9e09366e77f25d3d88c5393824e613344631be8db0d1839faca49686e99b6704", [:mix], [{:ex_aws, "~> 2.0", [hex: :ex_aws, repo: "hexpm", optional: false]}, {:sweet_xml, ">= 0.0.0", [hex: :sweet_xml, repo: "hexpm", optional: true]}], "hexpm"}, + "ex_aws": {:hex, :ex_aws, "2.1.1", "1e4de2106cfbf4e837de41be41cd15813eabc722315e388f0d6bb3732cec47cd", [:mix], [{:configparser_ex, "~> 4.0", [hex: :configparser_ex, repo: "hexpm", optional: true]}, {:hackney, "1.6.3 or 1.6.5 or 1.7.1 or 1.8.6 or ~> 1.9", [hex: :hackney, repo: "hexpm", optional: true]}, {:jsx, "~> 2.8", [hex: :jsx, repo: "hexpm", optional: true]}, {:poison, ">= 1.2.0", [hex: :poison, repo: "hexpm", optional: true]}, {:sweet_xml, "~> 0.6", [hex: :sweet_xml, repo: "hexpm", optional: true]}], "hexpm"}, + "ex_aws_s3": {:hex, :ex_aws_s3, "2.0.2", "c0258bbdfea55de4f98f0b2f0ca61fe402cc696f573815134beb1866e778f47b", [:mix], [{:ex_aws, "~> 2.0", [hex: :ex_aws, repo: "hexpm", optional: false]}, {:sweet_xml, ">= 0.0.0", [hex: :sweet_xml, repo: "hexpm", optional: true]}], "hexpm"}, "ex_const": {:hex, :ex_const, "0.2.4", "d06e540c9d834865b012a17407761455efa71d0ce91e5831e86881b9c9d82448", [:mix], [], "hexpm"}, "ex_doc": {:hex, :ex_doc, "0.21.2", "caca5bc28ed7b3bdc0b662f8afe2bee1eedb5c3cf7b322feeeb7c6ebbde089d6", [:mix], [{:earmark, "~> 1.3.3 or ~> 1.4", [hex: :earmark, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm"}, "ex_machina": {:hex, :ex_machina, "2.3.0", "92a5ad0a8b10ea6314b876a99c8c9e3f25f4dde71a2a835845b136b9adaf199a", [:mix], [{:ecto, "~> 2.2 or ~> 3.0", [hex: :ecto, repo: "hexpm", optional: true]}, {:ecto_sql, "~> 3.0", [hex: :ecto_sql, repo: "hexpm", optional: true]}], "hexpm"}, "ex_rated": {:hex, :ex_rated, "1.3.3", "30ecbdabe91f7eaa9d37fa4e81c85ba420f371babeb9d1910adbcd79ec798d27", [:mix], [{:ex2ms, "~> 1.5", [hex: :ex2ms, repo: "hexpm", optional: false]}], "hexpm"}, "ex_syslogger": {:git, "https://github.com/slashmili/ex_syslogger.git", "f3963399047af17e038897c69e20d552e6899e1d", [tag: "1.4.0"]}, - "excoveralls": {:hex, :excoveralls, "0.11.1", "dd677fbdd49114fdbdbf445540ec735808250d56b011077798316505064edb2c", [:mix], [{:hackney, "~> 1.0", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm"}, + "excoveralls": {:hex, :excoveralls, "0.11.2", "0c6f2c8db7683b0caa9d490fb8125709c54580b4255ffa7ad35f3264b075a643", [:mix], [{:hackney, "~> 1.0", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm"}, + "fast_sanitize": {:git, "https://git.pleroma.social/pleroma/fast_sanitize.git", "2820d841393b3c2f2183d0377f572bf00f513b7c", [ref: "2820d841393b3c2f2183d0377f572bf00f513b7c"]}, "flake_id": {:hex, :flake_id, "0.1.0", "7716b086d2e405d09b647121a166498a0d93d1a623bead243e1f74216079ccb3", [:mix], [{:base62, "~> 1.2", [hex: :base62, repo: "hexpm", optional: false]}, {:ecto, ">= 2.0.0", [hex: :ecto, repo: "hexpm", optional: true]}], "hexpm"}, "floki": {:hex, :floki, "0.23.0", "956ab6dba828c96e732454809fb0bd8d43ce0979b75f34de6322e73d4c917829", [:mix], [{:html_entities, "~> 0.4.0", [hex: :html_entities, repo: "hexpm", optional: false]}], "hexpm"}, - "gen_smtp": {:hex, :gen_smtp, "0.14.0", "39846a03522456077c6429b4badfd1d55e5e7d0fdfb65e935b7c5e38549d9202", [:rebar3], [], "hexpm"}, - "gen_stage": {:hex, :gen_stage, "0.14.2", "6a2a578a510c5bfca8a45e6b27552f613b41cf584b58210f017088d3d17d0b14", [:mix], [], "hexpm"}, + "gen_smtp": {:hex, :gen_smtp, "0.15.0", "9f51960c17769b26833b50df0b96123605a8024738b62db747fece14eb2fbfcc", [:rebar3], [], "hexpm"}, + "gen_stage": {:hex, :gen_stage, "0.14.3", "d0c66f1c87faa301c1a85a809a3ee9097a4264b2edf7644bf5c123237ef732bf", [:mix], [], "hexpm"}, "gen_state_machine": {:hex, :gen_state_machine, "2.0.5", "9ac15ec6e66acac994cc442dcc2c6f9796cf380ec4b08267223014be1c728a95", [:mix], [], "hexpm"}, - "gettext": {:hex, :gettext, "0.17.0", "abe21542c831887a2b16f4c94556db9c421ab301aee417b7c4fbde7fbdbe01ec", [:mix], [], "hexpm"}, + "gettext": {:hex, :gettext, "0.17.1", "8baab33482df4907b3eae22f719da492cee3981a26e649b9c2be1c0192616962", [:mix], [], "hexpm"}, "hackney": {:hex, :hackney, "1.15.2", "07e33c794f8f8964ee86cebec1a8ed88db5070e52e904b8f12209773c1036085", [:rebar3], [{:certifi, "2.5.1", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "6.0.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "~>1.1", [hex: :mimerl, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.5", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm"}, "html_entities": {:hex, :html_entities, "0.4.0", "f2fee876858cf6aaa9db608820a3209e45a087c5177332799592142b50e89a6b", [:mix], [], "hexpm"}, "html_sanitize_ex": {:hex, :html_sanitize_ex, "1.3.0", "f005ad692b717691203f940c686208aa3d8ffd9dd4bb3699240096a51fa9564e", [:mix], [{:mochiweb, "~> 2.15", [hex: :mochiweb, repo: "hexpm", optional: false]}], "hexpm"}, "http_signatures": {:git, "https://git.pleroma.social/pleroma/http_signatures.git", "293d77bb6f4a67ac8bde1428735c3b42f22cbb30", [ref: "293d77bb6f4a67ac8bde1428735c3b42f22cbb30"]}, - "httpoison": {:hex, :httpoison, "1.2.0", "2702ed3da5fd7a8130fc34b11965c8cfa21ade2f232c00b42d96d4967c39a3a3", [:mix], [{:hackney, "~> 1.8", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm"}, + "httpoison": {:hex, :httpoison, "1.6.1", "2ce5bf6e535cd0ab02e905ba8c276580bab80052c5c549f53ddea52d72e81f33", [:mix], [{:hackney, "~> 1.15 and >= 1.15.2", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm"}, "idna": {:hex, :idna, "6.0.0", "689c46cbcdf3524c44d5f3dde8001f364cd7608a99556d8fbd8239a5798d4c10", [:rebar3], [{:unicode_util_compat, "0.4.1", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm"}, "inet_cidr": {:hex, :inet_cidr, "1.0.4", "a05744ab7c221ca8e395c926c3919a821eb512e8f36547c062f62c4ca0cf3d6e", [:mix], [], "hexpm"}, "jason": {:hex, :jason, "1.1.2", "b03dedea67a99223a2eaf9f1264ce37154564de899fd3d8b9a21b1a6fd64afe7", [:mix], [{:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm"}, - "joken": {:hex, :joken, "2.0.1", "ec9ab31bf660f343380da033b3316855197c8d4c6ef597fa3fcb451b326beb14", [:mix], [{:jose, "~> 1.9", [hex: :jose, repo: "hexpm", optional: false]}], "hexpm"}, + "joken": {:hex, :joken, "2.1.0", "bf21a73105d82649f617c5e59a7f8919aa47013d2519ebcc39d998d8d12adda9", [:mix], [{:jose, "~> 1.9", [hex: :jose, repo: "hexpm", optional: false]}], "hexpm"}, "jose": {:hex, :jose, "1.9.0", "4167c5f6d06ffaebffd15cdb8da61a108445ef5e85ab8f5a7ad926fdf3ada154", [:mix, :rebar3], [{:base64url, "~> 0.0.1", [hex: :base64url, repo: "hexpm", optional: false]}], "hexpm"}, "libring": {:hex, :libring, "1.4.0", "41246ba2f3fbc76b3971f6bce83119dfec1eee17e977a48d8a9cfaaf58c2a8d6", [:mix], [], "hexpm"}, "makeup": {:hex, :makeup, "1.0.0", "671df94cf5a594b739ce03b0d0316aa64312cee2574b6a44becb83cd90fb05dc", [:mix], [{:nimble_parsec, "~> 0.5.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm"}, @@ -63,16 +64,18 @@ "mock": {:hex, :mock, "0.3.3", "42a433794b1291a9cf1525c6d26b38e039e0d3a360732b5e467bfc77ef26c914", [:mix], [{:meck, "~> 0.8.13", [hex: :meck, repo: "hexpm", optional: false]}], "hexpm"}, "mogrify": {:hex, :mogrify, "0.6.1", "de1b527514f2d95a7bbe9642eb556061afb337e220cf97adbf3a4e6438ed70af", [:mix], [], "hexpm"}, "mox": {:hex, :mox, "0.5.1", "f86bb36026aac1e6f924a4b6d024b05e9adbed5c63e8daa069bd66fb3292165b", [:mix], [], "hexpm"}, + "myhtmlex": {:git, "https://github.com/rinpatch/myhtmlex.git", "d973dfb1b252b1c6e6eddddc18c0895aa977091c", [ref: "d973dfb1b252b1c6e6eddddc18c0895aa977091c", submodules: true]}, "nimble_parsec": {:hex, :nimble_parsec, "0.5.1", "c90796ecee0289dbb5ad16d3ad06f957b0cd1199769641c961cfe0b97db190e0", [:mix], [], "hexpm"}, + "nodex": {:git, "https://github.com/rinpatch/nodex", "12ca7a2c5b5791f1e847d73ed646cf006d4c8ca8", [ref: "12ca7a2c5b5791f1e847d73ed646cf006d4c8ca8"]}, "oban": {:hex, :oban, "0.8.1", "4bbf62eb1829f856d69aeb5069ac7036afe07db8221a17de2a9169cc7a58a318", [:mix], [{:ecto_sql, "~> 3.1", [hex: :ecto_sql, repo: "hexpm", optional: false]}, {:jason, "~> 1.1", [hex: :jason, repo: "hexpm", optional: false]}, {:postgrex, "~> 0.14", [hex: :postgrex, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm"}, "parse_trans": {:hex, :parse_trans, "3.3.0", "09765507a3c7590a784615cfd421d101aec25098d50b89d7aa1d66646bc571c1", [:rebar3], [], "hexpm"}, - "pbkdf2_elixir": {:hex, :pbkdf2_elixir, "0.12.3", "6706a148809a29c306062862c803406e88f048277f6e85b68faf73291e820b84", [:mix], [], "hexpm"}, - "phoenix": {:hex, :phoenix, "1.4.9", "746d098e10741c334d88143d3c94cab1756435f94387a63441792e66ec0ee974", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 1.1", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:plug, "~> 1.8.1 or ~> 1.9", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 1.0 or ~> 2.0", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm"}, + "pbkdf2_elixir": {:hex, :pbkdf2_elixir, "0.12.4", "8dd29ed783f2e12195d7e0a4640effc0a7c37e6537da491f1db01839eee6d053", [:mix], [], "hexpm"}, + "phoenix": {:hex, :phoenix, "1.4.10", "619e4a545505f562cd294df52294372d012823f4fd9d34a6657a8b242898c255", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 1.1", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:plug, "~> 1.8.1 or ~> 1.9", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 1.0 or ~> 2.0", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm"}, "phoenix_ecto": {:hex, :phoenix_ecto, "4.0.0", "c43117a136e7399ea04ecaac73f8f23ee0ffe3e07acfcb8062fe5f4c9f0f6531", [:mix], [{:ecto, "~> 3.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 2.9", [hex: :phoenix_html, repo: "hexpm", optional: true]}, {:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"}, - "phoenix_html": {:hex, :phoenix_html, "2.13.1", "fa8f034b5328e2dfa0e4131b5569379003f34bc1fafdaa84985b0b9d2f12e68b", [:mix], [{:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"}, + "phoenix_html": {:hex, :phoenix_html, "2.13.3", "850e292ff6e204257f5f9c4c54a8cb1f6fbc16ed53d360c2b780a3d0ba333867", [:mix], [{:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"}, "phoenix_pubsub": {:hex, :phoenix_pubsub, "1.1.2", "496c303bdf1b2e98a9d26e89af5bba3ab487ba3a3735f74bf1f4064d2a845a3e", [:mix], [], "hexpm"}, "phoenix_swoosh": {:hex, :phoenix_swoosh, "0.2.0", "a7e0b32077cd6d2323ae15198839b05d9caddfa20663fd85787479e81f89520e", [:mix], [{:phoenix, "~> 1.0", [hex: :phoenix, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 2.2", [hex: :phoenix_html, repo: "hexpm", optional: false]}, {:swoosh, "~> 0.1", [hex: :swoosh, repo: "hexpm", optional: false]}], "hexpm"}, - "plug": {:hex, :plug, "1.8.2", "0bcce1daa420f189a6491f3940cc77ea7fb1919761175c9c3b59800d897440fc", [:mix], [{:mime, "~> 1.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.0", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: true]}], "hexpm"}, + "plug": {:hex, :plug, "1.8.3", "12d5f9796dc72e8ac9614e94bda5e51c4c028d0d428e9297650d09e15a684478", [:mix], [{:mime, "~> 1.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.0", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: true]}], "hexpm"}, "plug_cowboy": {:hex, :plug_cowboy, "2.1.0", "b75768153c3a8a9e8039d4b25bb9b14efbc58e9c4a6e6a270abff1cd30cbe320", [:mix], [{:cowboy, "~> 2.5", [hex: :cowboy, repo: "hexpm", optional: false]}, {:plug, "~> 1.7", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"}, "plug_crypto": {:hex, :plug_crypto, "1.0.0", "18e49317d3fa343f24620ed22795ec29d4a5e602d52d1513ccea0b07d8ea7d4d", [:mix], [], "hexpm"}, "plug_static_index_html": {:hex, :plug_static_index_html, "1.0.0", "840123d4d3975585133485ea86af73cb2600afd7f2a976f9f5fd8b3808e636a0", [:mix], [{:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"}, @@ -80,7 +83,7 @@ "poolboy": {:hex, :poolboy, "1.5.2", "392b007a1693a64540cead79830443abf5762f5d30cf50bc95cb2c1aaafa006b", [:rebar3], [], "hexpm"}, "postgrex": {:hex, :postgrex, "0.15.1", "23ce3417de70f4c0e9e7419ad85bdabcc6860a6925fe2c6f3b1b5b1e8e47bf2f", [:mix], [{:connection, "~> 1.0", [hex: :connection, repo: "hexpm", optional: false]}, {:db_connection, "~> 2.1", [hex: :db_connection, repo: "hexpm", optional: false]}, {:decimal, "~> 1.5", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm"}, "prometheus": {:hex, :prometheus, "4.4.1", "1e96073b3ed7788053768fea779cbc896ddc3bdd9ba60687f2ad50b252ac87d6", [:mix, :rebar3], [], "hexpm"}, - "prometheus_ecto": {:hex, :prometheus_ecto, "1.4.1", "6c768ea9654de871e5b32fab2eac348467b3021604ebebbcbd8bcbe806a65ed5", [:mix], [{:ecto, "~> 2.0 or ~> 3.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:prometheus_ex, "~> 1.1 or ~> 2.0 or ~> 3.0", [hex: :prometheus_ex, repo: "hexpm", optional: false]}], "hexpm"}, + "prometheus_ecto": {:hex, :prometheus_ecto, "1.4.3", "3dd4da1812b8e0dbee81ea58bb3b62ed7588f2eae0c9e97e434c46807ff82311", [:mix], [{:ecto, "~> 2.0 or ~> 3.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:prometheus_ex, "~> 1.1 or ~> 2.0 or ~> 3.0", [hex: :prometheus_ex, repo: "hexpm", optional: false]}], "hexpm"}, "prometheus_ex": {:hex, :prometheus_ex, "3.0.5", "fa58cfd983487fc5ead331e9a3e0aa622c67232b3ec71710ced122c4c453a02f", [:mix], [{:prometheus, "~> 4.0", [hex: :prometheus, repo: "hexpm", optional: false]}], "hexpm"}, "prometheus_phoenix": {:hex, :prometheus_phoenix, "1.3.0", "c4b527e0b3a9ef1af26bdcfbfad3998f37795b9185d475ca610fe4388fdd3bb5", [:mix], [{:phoenix, "~> 1.4", [hex: :phoenix, repo: "hexpm", optional: false]}, {:prometheus_ex, "~> 1.3 or ~> 2.0 or ~> 3.0", [hex: :prometheus_ex, repo: "hexpm", optional: false]}], "hexpm"}, "prometheus_plugs": {:hex, :prometheus_plugs, "1.1.5", "25933d48f8af3a5941dd7b621c889749894d8a1082a6ff7c67cc99dec26377c5", [:mix], [{:accept, "~> 0.1", [hex: :accept, repo: "hexpm", optional: false]}, {:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: false]}, {:prometheus_ex, "~> 1.1 or ~> 2.0 or ~> 3.0", [hex: :prometheus_ex, repo: "hexpm", optional: false]}, {:prometheus_process_collector, "~> 1.1", [hex: :prometheus_process_collector, repo: "hexpm", optional: true]}], "hexpm"}, @@ -92,16 +95,16 @@ "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.5", "6eaf7ad16cb568bb01753dbbd7a95ff8b91c7979482b95f38443fe2c8852a79b", [:make, :mix, :rebar3], [], "hexpm"}, "swarm": {:hex, :swarm, "3.4.0", "64f8b30055d74640d2186c66354b33b999438692a91be275bb89cdc7e401f448", [:mix], [{:gen_state_machine, "~> 2.0", [hex: :gen_state_machine, repo: "hexpm", optional: false]}, {:libring, "~> 1.0", [hex: :libring, repo: "hexpm", optional: false]}], "hexpm"}, "sweet_xml": {:hex, :sweet_xml, "0.6.6", "fc3e91ec5dd7c787b6195757fbcf0abc670cee1e4172687b45183032221b66b8", [:mix], [], "hexpm"}, - "swoosh": {:hex, :swoosh, "0.23.2", "7dda95ff0bf54a2298328d6899c74dae1223777b43563ccebebb4b5d2b61df38", [:mix], [{:cowboy, "~> 1.0.1 or ~> 1.1 or ~> 2.4", [hex: :cowboy, repo: "hexpm", optional: true]}, {:gen_smtp, "~> 0.13", [hex: :gen_smtp, repo: "hexpm", optional: true]}, {:hackney, "~> 1.9", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}, {:mail, "~> 0.2", [hex: :mail, repo: "hexpm", optional: true]}, {:mime, "~> 1.1", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_cowboy, ">= 1.0.0", [hex: :plug_cowboy, repo: "hexpm", optional: true]}], "hexpm"}, + "swoosh": {:hex, :swoosh, "0.23.5", "bfd9404bbf5069b1be2ffd317923ce57e58b332e25dbca2a35dedd7820dfee5a", [:mix], [{:cowboy, "~> 1.0.1 or ~> 1.1 or ~> 2.4", [hex: :cowboy, repo: "hexpm", optional: true]}, {:gen_smtp, "~> 0.13", [hex: :gen_smtp, repo: "hexpm", optional: true]}, {:hackney, "~> 1.9", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}, {:mail, "~> 0.2", [hex: :mail, repo: "hexpm", optional: true]}, {:mime, "~> 1.1", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_cowboy, ">= 1.0.0", [hex: :plug_cowboy, repo: "hexpm", optional: true]}], "hexpm"}, "syslog": {:git, "https://github.com/Vagabond/erlang-syslog.git", "4a6c6f2c996483e86c1320e9553f91d337bcb6aa", [tag: "1.0.5"]}, "telemetry": {:hex, :telemetry, "0.4.0", "8339bee3fa8b91cb84d14c2935f8ecf399ccd87301ad6da6b71c09553834b2ab", [:rebar3], [], "hexpm"}, "tesla": {:hex, :tesla, "1.3.0", "f35d72f029e608f9cdc6f6d6fcc7c66cf6d6512a70cfef9206b21b8bd0203a30", [:mix], [{:castore, "~> 0.1", [hex: :castore, repo: "hexpm", optional: true]}, {:exjsx, ">= 3.0.0", [hex: :exjsx, repo: "hexpm", optional: true]}, {:fuse, "~> 2.4", [hex: :fuse, repo: "hexpm", optional: true]}, {:gun, "~> 1.3", [hex: :gun, repo: "hexpm", optional: true]}, {:hackney, "~> 1.6", [hex: :hackney, repo: "hexpm", optional: true]}, {:ibrowse, "~> 4.4.0", [hex: :ibrowse, repo: "hexpm", optional: true]}, {:jason, ">= 1.0.0", [hex: :jason, repo: "hexpm", optional: true]}, {:mime, "~> 1.0", [hex: :mime, repo: "hexpm", optional: false]}, {:mint, "~> 0.4", [hex: :mint, repo: "hexpm", optional: true]}, {:poison, ">= 1.0.0", [hex: :poison, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.3", [hex: :telemetry, repo: "hexpm", optional: true]}], "hexpm"}, "timex": {:hex, :timex, "3.6.1", "efdf56d0e67a6b956cc57774353b0329c8ab7726766a11547e529357ffdc1d56", [:mix], [{:combine, "~> 0.10", [hex: :combine, repo: "hexpm", optional: false]}, {:gettext, "~> 0.10", [hex: :gettext, repo: "hexpm", optional: false]}, {:tzdata, "~> 0.1.8 or ~> 0.5 or ~> 1.0.0", [hex: :tzdata, repo: "hexpm", optional: false]}], "hexpm"}, "trailing_format_plug": {:hex, :trailing_format_plug, "0.0.7", "64b877f912cf7273bed03379936df39894149e35137ac9509117e59866e10e45", [:mix], [{:plug, "> 0.12.0", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"}, - "tzdata": {:hex, :tzdata, "0.5.21", "8cbf3607fcce69636c672d5be2bbb08687fe26639a62bdcc283d267277db7cf0", [:mix], [{:hackney, "~> 1.0", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm"}, - "ueberauth": {:hex, :ueberauth, "0.6.1", "9e90d3337dddf38b1ca2753aca9b1e53d8a52b890191cdc55240247c89230412", [:mix], [{:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"}, + "tzdata": {:hex, :tzdata, "0.5.22", "f2ba9105117ee0360eae2eca389783ef7db36d533899b2e84559404dbc77ebb8", [:mix], [{:hackney, "~> 1.0", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm"}, + "ueberauth": {:hex, :ueberauth, "0.6.2", "25a31111249d60bad8b65438b2306a4dc91f3208faa62f5a8c33e8713989b2e8", [:mix], [{:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"}, "unicode_util_compat": {:hex, :unicode_util_compat, "0.4.1", "d869e4c68901dd9531385bb0c8c40444ebf624e60b6962d95952775cac5e90cd", [:rebar3], [], "hexpm"}, "unsafe": {:hex, :unsafe, "1.0.1", "a27e1874f72ee49312e0a9ec2e0b27924214a05e3ddac90e91727bc76f8613d8", [:mix], [], "hexpm"}, - "web_push_encryption": {:hex, :web_push_encryption, "0.2.1", "d42cecf73420d9dc0053ba3299cc8c8d6ff2be2487d67ca2a57265868e4d9a98", [:mix], [{:httpoison, "~> 1.0", [hex: :httpoison, repo: "hexpm", optional: false]}, {:jose, "~> 1.8", [hex: :jose, repo: "hexpm", optional: false]}, {:poison, "~> 3.0", [hex: :poison, repo: "hexpm", optional: false]}], "hexpm"}, + "web_push_encryption": {:hex, :web_push_encryption, "0.2.3", "a0ceab85a805a30852f143d22d71c434046fbdbafbc7292e7887cec500826a80", [:mix], [{:httpoison, "~> 1.0", [hex: :httpoison, repo: "hexpm", optional: false]}, {:jose, "~> 1.8", [hex: :jose, repo: "hexpm", optional: false]}, {:poison, "~> 3.0", [hex: :poison, repo: "hexpm", optional: false]}], "hexpm"}, "websocket_client": {:git, "https://github.com/jeremyong/websocket_client.git", "9a6f65d05ebf2725d62fb19262b21f1805a59fbf", []}, } From 0c361eeb25230b20e1294fc022b20bf1e4be7d05 Mon Sep 17 00:00:00 2001 From: kPherox Date: Tue, 29 Oct 2019 17:12:49 +0900 Subject: [PATCH 042/154] Add pending to handle incoming for Follow activity --- lib/pleroma/web/activity_pub/transmogrifier.ex | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pleroma/web/activity_pub/transmogrifier.ex b/lib/pleroma/web/activity_pub/transmogrifier.ex index 3c27b0d46..91a164eff 100644 --- a/lib/pleroma/web/activity_pub/transmogrifier.ex +++ b/lib/pleroma/web/activity_pub/transmogrifier.ex @@ -507,6 +507,7 @@ def handle_incoming( }) {:user_locked, true} -> + {:ok, _relationship} = FollowingRelationship.update(follower, followed, "pending") :noop end From c2f2d7bcf66327b0eabf008f3819b374248c3ac2 Mon Sep 17 00:00:00 2001 From: kPherox Date: Tue, 29 Oct 2019 18:46:22 +0900 Subject: [PATCH 043/154] Add test follow activity for locked account --- test/web/activity_pub/transmogrifier_test.exs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/web/activity_pub/transmogrifier_test.exs b/test/web/activity_pub/transmogrifier_test.exs index 2f25c40d2..d920b969a 100644 --- a/test/web/activity_pub/transmogrifier_test.exs +++ b/test/web/activity_pub/transmogrifier_test.exs @@ -804,6 +804,25 @@ test "it works for incomming unfollows with an existing follow" do refute User.following?(User.get_cached_by_ap_id(data["actor"]), user) end + test "it works for incoming follows to locked account" do + pending_follower = insert(:user, ap_id: "http://mastodon.example.org/users/admin") + user = insert(:user, locked: true) + + data = + File.read!("test/fixtures/mastodon-follow-activity.json") + |> Poison.decode!() + |> Map.put("object", user.ap_id) + + {:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data) + + assert data["type"] == "Follow" + assert data["object"] == user.ap_id + assert data["state"] == "pending" + assert data["actor"] == "http://mastodon.example.org/users/admin" + + assert [^pending_follower] = User.get_follow_requests(user) + end + test "it works for incoming blocks" do user = insert(:user) From 41c23251f16ea1951cfea7da3fc809b9e71c25e8 Mon Sep 17 00:00:00 2001 From: rinpatch Date: Tue, 29 Oct 2019 13:05:20 +0300 Subject: [PATCH 044/154] Bump fast_sanitize version --- mix.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mix.exs b/mix.exs index 0e7c6a6f8..faff7033c 100644 --- a/mix.exs +++ b/mix.exs @@ -109,7 +109,7 @@ defp deps do {:pbkdf2_elixir, "~> 0.12.3"}, {:trailing_format_plug, "~> 0.0.7"}, {:html_sanitize_ex, "~> 1.3.0"}, - {:fast_sanitize, git: "https://git.pleroma.social/pleroma/fast_sanitize.git", ref: "2820d841393b3c2f2183d0377f572bf00f513b7c"}, + {:fast_sanitize, git: "https://git.pleroma.social/pleroma/fast_sanitize.git", ref: "0d996cac23e86afc342a24047e77443661bbbb13"}, {:html_entities, "~> 0.4"}, {:phoenix_html, "~> 2.10"}, {:calendar, "~> 0.17.4"}, From 5334190056b853dda57f16cbbaa230e8947821c6 Mon Sep 17 00:00:00 2001 From: kPherox Date: Tue, 29 Oct 2019 19:16:34 +0900 Subject: [PATCH 045/154] Migrate missing follow requests --- ...101340_migrate_missing_follow_requests.exs | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 priv/repo/migrations/20191029101340_migrate_missing_follow_requests.exs diff --git a/priv/repo/migrations/20191029101340_migrate_missing_follow_requests.exs b/priv/repo/migrations/20191029101340_migrate_missing_follow_requests.exs new file mode 100644 index 000000000..1b2666f3a --- /dev/null +++ b/priv/repo/migrations/20191029101340_migrate_missing_follow_requests.exs @@ -0,0 +1,35 @@ +defmodule Pleroma.Repo.Migrations.MigrateFollowingRelationships do + use Ecto.Migration + + def change do + execute(import_pending_follows_from_activities(), "") + end + + defp import_pending_follows_from_activities do + """ + INSERT INTO + following_relationships ( + follower_id, + following_id, + state, + inserted_at, + updated_at + ) + SELECT + followers.id, + following.id, + activities.data ->> 'state', + (activities.data ->> 'published') :: timestamp, + now() + FROM + activities + JOIN users AS followers ON (activities.actor = followers.ap_id) + JOIN users AS following ON (activities.data ->> 'object' = following.ap_id) + WHERE + activities.data ->> 'type' = 'Follow' + AND activities.data ->> 'state' = 'pending' + ORDER BY activities.updated_at DESC + ON CONFLICT DO NOTHING + """ + end +end From 3e09b7c5ae2d8e6d3abb2020f2c63caad278e73f Mon Sep 17 00:00:00 2001 From: rinpatch Date: Tue, 29 Oct 2019 16:56:24 +0300 Subject: [PATCH 046/154] Fix two migrations sharing the same module name This makes ecto execute only the latter one. --- .../20191029101340_migrate_missing_follow_requests.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/priv/repo/migrations/20191029101340_migrate_missing_follow_requests.exs b/priv/repo/migrations/20191029101340_migrate_missing_follow_requests.exs index 1b2666f3a..90b18efc8 100644 --- a/priv/repo/migrations/20191029101340_migrate_missing_follow_requests.exs +++ b/priv/repo/migrations/20191029101340_migrate_missing_follow_requests.exs @@ -1,4 +1,4 @@ -defmodule Pleroma.Repo.Migrations.MigrateFollowingRelationships do +defmodule Pleroma.Repo.Migrations.MigrateMissingFollowingRelationships do use Ecto.Migration def change do From 7358cf1f2041329f0924fc60106dfb5ec0288feb Mon Sep 17 00:00:00 2001 From: rinpatch Date: Tue, 29 Oct 2019 17:00:03 +0300 Subject: [PATCH 047/154] Bump fast_sanitize dependency --- mix.exs | 2 +- mix.lock | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mix.exs b/mix.exs index faff7033c..e46f9b2a4 100644 --- a/mix.exs +++ b/mix.exs @@ -109,7 +109,7 @@ defp deps do {:pbkdf2_elixir, "~> 0.12.3"}, {:trailing_format_plug, "~> 0.0.7"}, {:html_sanitize_ex, "~> 1.3.0"}, - {:fast_sanitize, git: "https://git.pleroma.social/pleroma/fast_sanitize.git", ref: "0d996cac23e86afc342a24047e77443661bbbb13"}, + {:fast_sanitize, git: "https://git.pleroma.social/pleroma/fast_sanitize.git", ref: "a23fbf1bd77b002a8f72a53c39c53b176f98f81a"}, {:html_entities, "~> 0.4"}, {:phoenix_html, "~> 2.10"}, {:calendar, "~> 0.17.4"}, diff --git a/mix.lock b/mix.lock index 18e2572dd..01f6860a6 100644 --- a/mix.lock +++ b/mix.lock @@ -36,7 +36,7 @@ "ex_rated": {:hex, :ex_rated, "1.3.3", "30ecbdabe91f7eaa9d37fa4e81c85ba420f371babeb9d1910adbcd79ec798d27", [:mix], [{:ex2ms, "~> 1.5", [hex: :ex2ms, repo: "hexpm", optional: false]}], "hexpm"}, "ex_syslogger": {:git, "https://github.com/slashmili/ex_syslogger.git", "f3963399047af17e038897c69e20d552e6899e1d", [tag: "1.4.0"]}, "excoveralls": {:hex, :excoveralls, "0.11.2", "0c6f2c8db7683b0caa9d490fb8125709c54580b4255ffa7ad35f3264b075a643", [:mix], [{:hackney, "~> 1.0", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm"}, - "fast_sanitize": {:git, "https://git.pleroma.social/pleroma/fast_sanitize.git", "2820d841393b3c2f2183d0377f572bf00f513b7c", [ref: "2820d841393b3c2f2183d0377f572bf00f513b7c"]}, + "fast_sanitize": {:git, "https://git.pleroma.social/pleroma/fast_sanitize.git", "a23fbf1bd77b002a8f72a53c39c53b176f98f81a", [ref: "a23fbf1bd77b002a8f72a53c39c53b176f98f81a"]}, "flake_id": {:hex, :flake_id, "0.1.0", "7716b086d2e405d09b647121a166498a0d93d1a623bead243e1f74216079ccb3", [:mix], [{:base62, "~> 1.2", [hex: :base62, repo: "hexpm", optional: false]}, {:ecto, ">= 2.0.0", [hex: :ecto, repo: "hexpm", optional: true]}], "hexpm"}, "floki": {:hex, :floki, "0.23.0", "956ab6dba828c96e732454809fb0bd8d43ce0979b75f34de6322e73d4c917829", [:mix], [{:html_entities, "~> 0.4.0", [hex: :html_entities, repo: "hexpm", optional: false]}], "hexpm"}, "gen_smtp": {:hex, :gen_smtp, "0.15.0", "9f51960c17769b26833b50df0b96123605a8024738b62db747fece14eb2fbfcc", [:rebar3], [], "hexpm"}, @@ -64,7 +64,7 @@ "mock": {:hex, :mock, "0.3.3", "42a433794b1291a9cf1525c6d26b38e039e0d3a360732b5e467bfc77ef26c914", [:mix], [{:meck, "~> 0.8.13", [hex: :meck, repo: "hexpm", optional: false]}], "hexpm"}, "mogrify": {:hex, :mogrify, "0.6.1", "de1b527514f2d95a7bbe9642eb556061afb337e220cf97adbf3a4e6438ed70af", [:mix], [], "hexpm"}, "mox": {:hex, :mox, "0.5.1", "f86bb36026aac1e6f924a4b6d024b05e9adbed5c63e8daa069bd66fb3292165b", [:mix], [], "hexpm"}, - "myhtmlex": {:git, "https://github.com/rinpatch/myhtmlex.git", "d973dfb1b252b1c6e6eddddc18c0895aa977091c", [ref: "d973dfb1b252b1c6e6eddddc18c0895aa977091c", submodules: true]}, + "myhtmlex": {:git, "https://github.com/rinpatch/myhtmlex.git", "2031aeb1098e128f35a6a0b54841e259fc7672d5", [ref: "2031aeb1098e128f35a6a0b54841e259fc7672d5", submodules: true]}, "nimble_parsec": {:hex, :nimble_parsec, "0.5.1", "c90796ecee0289dbb5ad16d3ad06f957b0cd1199769641c961cfe0b97db190e0", [:mix], [], "hexpm"}, "nodex": {:git, "https://github.com/rinpatch/nodex", "12ca7a2c5b5791f1e847d73ed646cf006d4c8ca8", [ref: "12ca7a2c5b5791f1e847d73ed646cf006d4c8ca8"]}, "oban": {:hex, :oban, "0.8.1", "4bbf62eb1829f856d69aeb5069ac7036afe07db8221a17de2a9169cc7a58a318", [:mix], [{:ecto_sql, "~> 3.1", [hex: :ecto_sql, repo: "hexpm", optional: false]}, {:jason, "~> 1.1", [hex: :jason, repo: "hexpm", optional: false]}, {:postgrex, "~> 0.14", [hex: :postgrex, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm"}, From 61400d7eb785f41ab853f42d0a221357253c39eb Mon Sep 17 00:00:00 2001 From: rinpatch Date: Tue, 29 Oct 2019 20:49:32 +0300 Subject: [PATCH 048/154] Fix XSS emoji test --- mix.exs | 2 +- mix.lock | 6 +++--- test/emoji/formatter_test.exs | 5 +---- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/mix.exs b/mix.exs index e46f9b2a4..2e64b79ad 100644 --- a/mix.exs +++ b/mix.exs @@ -109,7 +109,7 @@ defp deps do {:pbkdf2_elixir, "~> 0.12.3"}, {:trailing_format_plug, "~> 0.0.7"}, {:html_sanitize_ex, "~> 1.3.0"}, - {:fast_sanitize, git: "https://git.pleroma.social/pleroma/fast_sanitize.git", ref: "a23fbf1bd77b002a8f72a53c39c53b176f98f81a"}, + {:fast_sanitize, git: "https://git.pleroma.social/pleroma/fast_sanitize.git", ref: "37f55e2bbe6eb44e8a9c4b3831a5ce73a2f6955c"}, {:html_entities, "~> 0.4"}, {:phoenix_html, "~> 2.10"}, {:calendar, "~> 0.17.4"}, diff --git a/mix.lock b/mix.lock index 01f6860a6..6cbe54a76 100644 --- a/mix.lock +++ b/mix.lock @@ -36,7 +36,7 @@ "ex_rated": {:hex, :ex_rated, "1.3.3", "30ecbdabe91f7eaa9d37fa4e81c85ba420f371babeb9d1910adbcd79ec798d27", [:mix], [{:ex2ms, "~> 1.5", [hex: :ex2ms, repo: "hexpm", optional: false]}], "hexpm"}, "ex_syslogger": {:git, "https://github.com/slashmili/ex_syslogger.git", "f3963399047af17e038897c69e20d552e6899e1d", [tag: "1.4.0"]}, "excoveralls": {:hex, :excoveralls, "0.11.2", "0c6f2c8db7683b0caa9d490fb8125709c54580b4255ffa7ad35f3264b075a643", [:mix], [{:hackney, "~> 1.0", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm"}, - "fast_sanitize": {:git, "https://git.pleroma.social/pleroma/fast_sanitize.git", "a23fbf1bd77b002a8f72a53c39c53b176f98f81a", [ref: "a23fbf1bd77b002a8f72a53c39c53b176f98f81a"]}, + "fast_sanitize": {:git, "https://git.pleroma.social/pleroma/fast_sanitize.git", "37f55e2bbe6eb44e8a9c4b3831a5ce73a2f6955c", [ref: "37f55e2bbe6eb44e8a9c4b3831a5ce73a2f6955c"]}, "flake_id": {:hex, :flake_id, "0.1.0", "7716b086d2e405d09b647121a166498a0d93d1a623bead243e1f74216079ccb3", [:mix], [{:base62, "~> 1.2", [hex: :base62, repo: "hexpm", optional: false]}, {:ecto, ">= 2.0.0", [hex: :ecto, repo: "hexpm", optional: true]}], "hexpm"}, "floki": {:hex, :floki, "0.23.0", "956ab6dba828c96e732454809fb0bd8d43ce0979b75f34de6322e73d4c917829", [:mix], [{:html_entities, "~> 0.4.0", [hex: :html_entities, repo: "hexpm", optional: false]}], "hexpm"}, "gen_smtp": {:hex, :gen_smtp, "0.15.0", "9f51960c17769b26833b50df0b96123605a8024738b62db747fece14eb2fbfcc", [:rebar3], [], "hexpm"}, @@ -64,9 +64,9 @@ "mock": {:hex, :mock, "0.3.3", "42a433794b1291a9cf1525c6d26b38e039e0d3a360732b5e467bfc77ef26c914", [:mix], [{:meck, "~> 0.8.13", [hex: :meck, repo: "hexpm", optional: false]}], "hexpm"}, "mogrify": {:hex, :mogrify, "0.6.1", "de1b527514f2d95a7bbe9642eb556061afb337e220cf97adbf3a4e6438ed70af", [:mix], [], "hexpm"}, "mox": {:hex, :mox, "0.5.1", "f86bb36026aac1e6f924a4b6d024b05e9adbed5c63e8daa069bd66fb3292165b", [:mix], [], "hexpm"}, - "myhtmlex": {:git, "https://github.com/rinpatch/myhtmlex.git", "2031aeb1098e128f35a6a0b54841e259fc7672d5", [ref: "2031aeb1098e128f35a6a0b54841e259fc7672d5", submodules: true]}, + "myhtmlex": {:git, "https://git.pleroma.social/pleroma/myhtmlex.git", "eafbba443260c0055ef2da3918b351b112ff356f", [ref: "eafbba443260c0055ef2da3918b351b112ff356f", submodules: true]}, "nimble_parsec": {:hex, :nimble_parsec, "0.5.1", "c90796ecee0289dbb5ad16d3ad06f957b0cd1199769641c961cfe0b97db190e0", [:mix], [], "hexpm"}, - "nodex": {:git, "https://github.com/rinpatch/nodex", "12ca7a2c5b5791f1e847d73ed646cf006d4c8ca8", [ref: "12ca7a2c5b5791f1e847d73ed646cf006d4c8ca8"]}, + "nodex": {:git, "https://git.pleroma.social/pleroma/nodex", "2927091d96900fb76f6bc897e46a6abb9070ebbd", [ref: "2927091d96900fb76f6bc897e46a6abb9070ebbd"]}, "oban": {:hex, :oban, "0.8.1", "4bbf62eb1829f856d69aeb5069ac7036afe07db8221a17de2a9169cc7a58a318", [:mix], [{:ecto_sql, "~> 3.1", [hex: :ecto_sql, repo: "hexpm", optional: false]}, {:jason, "~> 1.1", [hex: :jason, repo: "hexpm", optional: false]}, {:postgrex, "~> 0.14", [hex: :postgrex, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm"}, "parse_trans": {:hex, :parse_trans, "3.3.0", "09765507a3c7590a784615cfd421d101aec25098d50b89d7aa1d66646bc571c1", [:rebar3], [], "hexpm"}, "pbkdf2_elixir": {:hex, :pbkdf2_elixir, "0.12.4", "8dd29ed783f2e12195d7e0a4640effc0a7c37e6537da491f1db01839eee6d053", [:mix], [], "hexpm"}, diff --git a/test/emoji/formatter_test.exs b/test/emoji/formatter_test.exs index 3e37ae3f0..fda80d470 100644 --- a/test/emoji/formatter_test.exs +++ b/test/emoji/formatter_test.exs @@ -28,10 +28,7 @@ test "it does not add XSS emoji" do } |> Pleroma.Emoji.build() - expected_result = - "I love \"\"" - - assert Formatter.emojify(text, [{custom_emoji.code, custom_emoji}]) == expected_result + refute Formatter.emojify(text, [{custom_emoji.code, custom_emoji}]) =~ text end end From 77cfb08b8c4c07406af8b338ce010307f6af75cb Mon Sep 17 00:00:00 2001 From: rinpatch Date: Tue, 29 Oct 2019 20:58:54 +0300 Subject: [PATCH 049/154] Remove commented-out code --- lib/pleroma/html.ex | 3 +-- mix.exs | 4 +++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/pleroma/html.ex b/lib/pleroma/html.ex index fd0495049..294bc75f9 100644 --- a/lib/pleroma/html.ex +++ b/lib/pleroma/html.ex @@ -3,7 +3,6 @@ # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.HTML do - 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] @@ -39,6 +38,7 @@ def get_cached_scrubbed_html_for_activity( callback \\ fn x -> x end ) do key = "#{key}#{generate_scrubber_signature(scrubbers)}|#{activity.id}" + Cachex.fetch!(:scrubber_cache, key, fn _key -> object = Pleroma.Object.normalize(activity) ensure_scrubbed_html(content, scrubbers, object.data["fake"] || false, callback) @@ -168,7 +168,6 @@ defmodule Pleroma.HTML.Scrubber.Default do @valid_schemes Pleroma.Config.get([:uri_schemes, :valid_schemes], []) -# Meta.remove_cdata_sections_before_scrub() Meta.strip_comments() Meta.allow_tag_with_uri_attributes(:a, ["href", "data-user", "data-tag"], @valid_schemes) diff --git a/mix.exs b/mix.exs index 2e64b79ad..91b79dde2 100644 --- a/mix.exs +++ b/mix.exs @@ -109,7 +109,9 @@ defp deps do {:pbkdf2_elixir, "~> 0.12.3"}, {:trailing_format_plug, "~> 0.0.7"}, {:html_sanitize_ex, "~> 1.3.0"}, - {:fast_sanitize, git: "https://git.pleroma.social/pleroma/fast_sanitize.git", ref: "37f55e2bbe6eb44e8a9c4b3831a5ce73a2f6955c"}, + {:fast_sanitize, + git: "https://git.pleroma.social/pleroma/fast_sanitize.git", + ref: "37f55e2bbe6eb44e8a9c4b3831a5ce73a2f6955c"}, {:html_entities, "~> 0.4"}, {:phoenix_html, "~> 2.10"}, {:calendar, "~> 0.17.4"}, From ae59b38203b5358ddbf7f2cc5e2cbc816d171452 Mon Sep 17 00:00:00 2001 From: rinpatch Date: Wed, 30 Oct 2019 09:20:13 +0300 Subject: [PATCH 050/154] Rip out the rest of htmlsanitizeex --- lib/pleroma/bbs/handler.ex | 3 ++- lib/pleroma/html.ex | 9 ++++----- mix.exs | 1 - test/web/mastodon_api/views/status_view_test.exs | 9 +++++---- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/pleroma/bbs/handler.ex b/lib/pleroma/bbs/handler.ex index fa838a4e4..386afee89 100644 --- a/lib/pleroma/bbs/handler.ex +++ b/lib/pleroma/bbs/handler.ex @@ -5,6 +5,7 @@ defmodule Pleroma.BBS.Handler do use Sshd.ShellHandler alias Pleroma.Activity + alias Pleroma.HTML alias Pleroma.Web.ActivityPub.ActivityPub alias Pleroma.Web.CommonAPI @@ -44,7 +45,7 @@ defp loop(state) do def puts_activity(activity) do status = Pleroma.Web.MastodonAPI.StatusView.render("show.json", %{activity: activity}) IO.puts("-- #{status.id} by #{status.account.display_name} (#{status.account.acct})") - IO.puts(HtmlSanitizeEx.strip_tags(status.content)) + IO.puts(HTML.strip_tags(status.content)) IO.puts("") end diff --git a/lib/pleroma/html.ex b/lib/pleroma/html.ex index 294bc75f9..997e965f0 100644 --- a/lib/pleroma/html.ex +++ b/lib/pleroma/html.ex @@ -108,8 +108,8 @@ defmodule Pleroma.HTML.Scrubber.TwitterText do @valid_schemes Pleroma.Config.get([:uri_schemes, :valid_schemes], []) - require HtmlSanitizeEx.Scrubber.Meta - alias HtmlSanitizeEx.Scrubber.Meta + require FastSanitize.Sanitizer.Meta + alias FastSanitize.Sanitizer.Meta Meta.strip_comments() @@ -291,10 +291,9 @@ defmodule Pleroma.HTML.Scrubber.LinksOnly do @valid_schemes Pleroma.Config.get([:uri_schemes, :valid_schemes], []) - require HtmlSanitizeEx.Scrubber.Meta - alias HtmlSanitizeEx.Scrubber.Meta + require FastSanitize.Sanitizer.Meta + alias FastSanitize.Sanitizer.Meta - Meta.remove_cdata_sections_before_scrub() Meta.strip_comments() # links diff --git a/mix.exs b/mix.exs index 91b79dde2..e85c2aa50 100644 --- a/mix.exs +++ b/mix.exs @@ -108,7 +108,6 @@ defp deps do {:comeonin, "~> 4.1.1"}, {:pbkdf2_elixir, "~> 0.12.3"}, {:trailing_format_plug, "~> 0.0.7"}, - {:html_sanitize_ex, "~> 1.3.0"}, {:fast_sanitize, git: "https://git.pleroma.social/pleroma/fast_sanitize.git", ref: "37f55e2bbe6eb44e8a9c4b3831a5ce73a2f6955c"}, diff --git a/test/web/mastodon_api/views/status_view_test.exs b/test/web/mastodon_api/views/status_view_test.exs index c200ad8fe..7526f2f27 100644 --- a/test/web/mastodon_api/views/status_view_test.exs +++ b/test/web/mastodon_api/views/status_view_test.exs @@ -7,6 +7,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do alias Pleroma.Activity alias Pleroma.Bookmark + alias Pleroma.HTML alias Pleroma.Object alias Pleroma.Repo alias Pleroma.User @@ -107,7 +108,7 @@ test "a note activity" do in_reply_to_account_id: nil, card: nil, reblog: nil, - content: HtmlSanitizeEx.basic_html(object_data["content"]), + content: HTML.filter_tags(object_data["content"]), created_at: created_at, reblogs_count: 0, replies_count: 0, @@ -119,7 +120,7 @@ test "a note activity" do pinned: false, sensitive: false, poll: nil, - spoiler_text: HtmlSanitizeEx.basic_html(object_data["summary"]), + spoiler_text: HTML.filter_tags(object_data["summary"]), visibility: "public", media_attachments: [], mentions: [], @@ -146,8 +147,8 @@ test "a note activity" do local: true, conversation_id: convo_id, in_reply_to_account_acct: nil, - content: %{"text/plain" => HtmlSanitizeEx.strip_tags(object_data["content"])}, - spoiler_text: %{"text/plain" => HtmlSanitizeEx.strip_tags(object_data["summary"])}, + content: %{"text/plain" => HTML.strip_tags(object_data["content"])}, + spoiler_text: %{"text/plain" => HTML.strip_tags(object_data["summary"])}, expires_at: nil, direct_conversation_id: nil, thread_muted: false From 363e76d4dac290f5f5081e95ad40f496ee81c1e5 Mon Sep 17 00:00:00 2001 From: kPherox Date: Wed, 30 Oct 2019 15:40:25 +0900 Subject: [PATCH 051/154] Fix duplicate recipients --- lib/pleroma/user/query.ex | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pleroma/user/query.ex b/lib/pleroma/user/query.ex index 2eda454bc..364bc1c89 100644 --- a/lib/pleroma/user/query.ex +++ b/lib/pleroma/user/query.ex @@ -175,6 +175,7 @@ defp compose_query({:recipients_from_activity, to}, query) do [u, following: f, relationships: r], u.ap_id in ^to or (f.follower_address in ^to and r.state == "accept") ) + |> distinct(true) end defp compose_query({:order_by, key}, query) do From 40d5fb6ef875262795d87b95bff1ef44ee75d659 Mon Sep 17 00:00:00 2001 From: Egor Kislitsyn Date: Wed, 30 Oct 2019 15:52:37 +0700 Subject: [PATCH 052/154] Add a migration to fix blocked follows --- .../20191029172832_fix_blocked_follows.exs | 112 ++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 priv/repo/migrations/20191029172832_fix_blocked_follows.exs diff --git a/priv/repo/migrations/20191029172832_fix_blocked_follows.exs b/priv/repo/migrations/20191029172832_fix_blocked_follows.exs new file mode 100644 index 000000000..71f8f1330 --- /dev/null +++ b/priv/repo/migrations/20191029172832_fix_blocked_follows.exs @@ -0,0 +1,112 @@ +defmodule Pleroma.Repo.Migrations.FixBlockedFollows do + use Ecto.Migration + + import Ecto.Query + alias Pleroma.Config + alias Pleroma.Repo + + def up do + unfollow_blocked = Config.get([:activitypub, :unfollow_blocked]) + + if unfollow_blocked do + "activities" + |> where([activity], fragment("? ->> 'type' = 'Block'", activity.data)) + |> distinct([activity], [ + activity.actor, + fragment( + "coalesce((?)->'object'->>'id', (?)->>'object')", + activity.data, + activity.data + ) + ]) + |> order_by([activity], [fragment("? desc nulls last", activity.id)]) + |> select([activity], %{ + blocker: activity.actor, + blocked: + fragment("coalesce((?)->'object'->>'id', (?)->>'object')", activity.data, activity.data), + created_at: activity.id + }) + |> Repo.stream() + |> Enum.map(&unfollow_if_blocked/1) + |> Enum.uniq() + |> Enum.each(&update_follower_count/1) + end + end + + def down do + end + + def unfollow_if_blocked(%{blocker: blocker_id, blocked: blocked_id, created_at: blocked_at}) do + query = + from( + activity in "activities", + where: fragment("? ->> 'type' = 'Follow'", activity.data), + where: activity.actor == ^blocked_id, + # this is to use the index + where: + fragment( + "coalesce((?)->'object'->>'id', (?)->>'object') = ?", + activity.data, + activity.data, + ^blocker_id + ), + where: activity.id > ^blocked_at, + where: fragment("(?)->>'state' = 'accept'", activity.data), + order_by: [fragment("? desc nulls last", activity.id)] + ) + + unless Repo.exists?(query) do + blocker = "users" |> select([:id, :local]) |> Repo.get_by(ap_id: blocker_id) + blocked = "users" |> select([:id]) |> Repo.get_by(ap_id: blocked_id) + + if !is_nil(blocker) && !is_nil(blocked) do + unfollow(blocked, blocker) + end + end + end + + def unfollow(%{id: follower_id}, %{id: followed_id} = followed) do + following_relationship = + "following_relationships" + |> where(follower_id: ^follower_id, following_id: ^followed_id, state: "accept") + |> select([:id]) + |> Repo.one() + + case following_relationship do + nil -> + {:ok, nil} + + %{id: following_relationship_id} -> + "following_relationships" + |> where(id: ^following_relationship_id) + |> Repo.delete_all() + + followed + end + end + + def update_follower_count(%{id: user_id} = user) do + if user.local or !Pleroma.Config.get([:instance, :external_user_synchronization]) do + follower_count_query = + "users" + |> where([u], u.id != ^user_id) + |> where([u], u.deactivated != ^true) + |> join(:inner, [u], r in "following_relationships", + as: :relationships, + on: r.following_id == ^user_id and r.follower_id == u.id + ) + |> where([relationships: r], r.state == "accept") + |> select([u], %{count: count(u.id)}) + + "users" + |> where(id: ^user_id) + |> join(:inner, [u], s in subquery(follower_count_query)) + |> update([u, s], + set: [follower_count: s.count] + ) + |> Repo.update_all([]) + end + end + + def update_follower_count(_), do: :noop +end From c546da7cfe800ee0a0ac2ecf9981bb131cd63291 Mon Sep 17 00:00:00 2001 From: rinpatch Date: Wed, 30 Oct 2019 12:59:14 +0300 Subject: [PATCH 053/154] Fix bookmark migration using a query with a schema This resulted in failures when updating from Pleroma <1.0 because of all the new fields that were added to the user schema. --- .../migrations/20190414125034_migrate_old_bookmarks.exs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/priv/repo/migrations/20190414125034_migrate_old_bookmarks.exs b/priv/repo/migrations/20190414125034_migrate_old_bookmarks.exs index f3928a149..99102117f 100644 --- a/priv/repo/migrations/20190414125034_migrate_old_bookmarks.exs +++ b/priv/repo/migrations/20190414125034_migrate_old_bookmarks.exs @@ -8,10 +8,10 @@ defmodule Pleroma.Repo.Migrations.MigrateOldBookmarks do def up do query = - from(u in User, + from(u in "users", where: u.local == true, - where: fragment("array_length(bookmarks, 1)") > 0, - select: %{id: u.id, bookmarks: fragment("bookmarks")} + where: fragment("array_length(?, 1)", u.bookmarks) > 0, + select: %{id: u.id, bookmarks: u.bookmarks} ) Repo.stream(query) From d1ae51b02a8f367a5dec6d427391e274caeac468 Mon Sep 17 00:00:00 2001 From: kPherox Date: Wed, 30 Oct 2019 20:14:07 +0900 Subject: [PATCH 054/154] Update test for get_recipients_from_activity --- test/user_test.exs | 59 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 41 insertions(+), 18 deletions(-) diff --git a/test/user_test.exs b/test/user_test.exs index 188295a86..6b1b24ce5 100644 --- a/test/user_test.exs +++ b/test/user_test.exs @@ -878,27 +878,50 @@ test "it imports user blocks from list" do end end - test "get recipients from activity" do - actor = insert(:user) - user = insert(:user, local: true) - user_two = insert(:user, local: false) - addressed = insert(:user, local: true) - addressed_remote = insert(:user, local: false) + describe "get_recipients_from_activity" do + test "get recipients" do + actor = insert(:user) + user = insert(:user, local: true) + user_two = insert(:user, local: false) + addressed = insert(:user, local: true) + addressed_remote = insert(:user, local: false) - {:ok, activity} = - CommonAPI.post(actor, %{ - "status" => "hey @#{addressed.nickname} @#{addressed_remote.nickname}" - }) + {:ok, activity} = + CommonAPI.post(actor, %{ + "status" => "hey @#{addressed.nickname} @#{addressed_remote.nickname}" + }) - assert Enum.map([actor, addressed], & &1.ap_id) -- - Enum.map(User.get_recipients_from_activity(activity), & &1.ap_id) == [] + assert Enum.map([actor, addressed], & &1.ap_id) -- + Enum.map(User.get_recipients_from_activity(activity), & &1.ap_id) == [] - {:ok, user} = User.follow(user, actor) - {:ok, _user_two} = User.follow(user_two, actor) - recipients = User.get_recipients_from_activity(activity) - assert length(recipients) == 3 - assert user in recipients - assert addressed in recipients + {:ok, user} = User.follow(user, actor) + {:ok, _user_two} = User.follow(user_two, actor) + recipients = User.get_recipients_from_activity(activity) + assert length(recipients) == 3 + assert user in recipients + assert addressed in recipients + end + + test "has following" do + actor = insert(:user) + user = insert(:user) + user_two = insert(:user) + addressed = insert(:user, local: true) + + {:ok, activity} = + CommonAPI.post(actor, %{ + "status" => "hey @#{addressed.nickname}" + }) + + assert Enum.map([actor, addressed], & &1.ap_id) -- + Enum.map(User.get_recipients_from_activity(activity), & &1.ap_id) == [] + + {:ok, _actor} = User.follow(actor, user) + {:ok, _actor} = User.follow(actor, user_two) + recipients = User.get_recipients_from_activity(activity) + assert length(recipients) == 2 + assert addressed in recipients + end end describe ".deactivate" do From 8bb6da7cd604359afb5eeabeeac0207edff07ce3 Mon Sep 17 00:00:00 2001 From: Roman Chvanikov Date: Wed, 30 Oct 2019 18:34:14 +0300 Subject: [PATCH 055/154] Remove following column from the migrations --- priv/repo/migrations/20191025143434_add_defaults_to_tables.exs | 3 --- priv/repo/migrations/20191026191910_set_not_null_for_users.exs | 2 -- 2 files changed, 5 deletions(-) diff --git a/priv/repo/migrations/20191025143434_add_defaults_to_tables.exs b/priv/repo/migrations/20191025143434_add_defaults_to_tables.exs index d16ab19f9..a5bc82335 100644 --- a/priv/repo/migrations/20191025143434_add_defaults_to_tables.exs +++ b/priv/repo/migrations/20191025143434_add_defaults_to_tables.exs @@ -12,7 +12,6 @@ def up do ALTER COLUMN data SET DEFAULT '{}'::jsonb") execute(~s(ALTER TABLE users - ALTER COLUMN following SET DEFAULT ARRAY[]::character varying[], ALTER COLUMN tags SET DEFAULT ARRAY[]::character varying[], ALTER COLUMN notification_settings SET DEFAULT '{"followers": true, "follows": true, "non_follows": true, "non_followers": true}'::jsonb)) @@ -46,7 +45,6 @@ def up do "UPDATE users SET pleroma_settings_store = '{}'::jsonb where pleroma_settings_store IS NULL" ) - execute("UPDATE users SET following = ARRAY[]::character varying[] WHERE following IS NULL") execute("UPDATE users SET tags = ARRAY[]::character varying[] WHERE tags IS NULL") execute(~s(UPDATE users SET notification_settings = '{"followers": true, "follows": true, "non_follows": true, "non_followers": true}'::jsonb @@ -64,7 +62,6 @@ def down do ALTER COLUMN data DROP DEFAULT") execute("ALTER TABLE users - ALTER COLUMN following DROP DEFAULT, ALTER COLUMN tags DROP DEFAULT, ALTER COLUMN notification_settings SET DEFAULT '{}'::jsonb") end diff --git a/priv/repo/migrations/20191026191910_set_not_null_for_users.exs b/priv/repo/migrations/20191026191910_set_not_null_for_users.exs index f145a89ab..9d8d0ccf8 100644 --- a/priv/repo/migrations/20191026191910_set_not_null_for_users.exs +++ b/priv/repo/migrations/20191026191910_set_not_null_for_users.exs @@ -8,7 +8,6 @@ def up do execute("UPDATE users SET follower_count = 0 WHERE follower_count IS NULL") execute("ALTER TABLE users - ALTER COLUMN following SET NOT NULL, ALTER COLUMN local SET NOT NULL, ALTER COLUMN source_data SET NOT NULL, ALTER COLUMN note_count SET NOT NULL, @@ -27,7 +26,6 @@ def up do def down do execute("ALTER TABLE users - ALTER COLUMN following DROP NOT NULL, ALTER COLUMN local DROP NOT NULL, ALTER COLUMN source_data DROP NOT NULL, ALTER COLUMN note_count DROP NOT NULL, From bd0f7f2e09ec4d2883b87fd3c5d3784319de7cc7 Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Wed, 30 Oct 2019 17:57:08 -0500 Subject: [PATCH 056/154] Bump fast_sanitize dependency so this builds on more than just Linux --- mix.exs | 2 +- mix.lock | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mix.exs b/mix.exs index e85c2aa50..66cea7b89 100644 --- a/mix.exs +++ b/mix.exs @@ -110,7 +110,7 @@ defp deps do {:trailing_format_plug, "~> 0.0.7"}, {:fast_sanitize, git: "https://git.pleroma.social/pleroma/fast_sanitize.git", - ref: "37f55e2bbe6eb44e8a9c4b3831a5ce73a2f6955c"}, + ref: "d5c47d580a018c4e7f6fadfca63834b9ae28c18c"}, {:html_entities, "~> 0.4"}, {:phoenix_html, "~> 2.10"}, {:calendar, "~> 0.17.4"}, diff --git a/mix.lock b/mix.lock index 6cbe54a76..802cb2959 100644 --- a/mix.lock +++ b/mix.lock @@ -36,7 +36,7 @@ "ex_rated": {:hex, :ex_rated, "1.3.3", "30ecbdabe91f7eaa9d37fa4e81c85ba420f371babeb9d1910adbcd79ec798d27", [:mix], [{:ex2ms, "~> 1.5", [hex: :ex2ms, repo: "hexpm", optional: false]}], "hexpm"}, "ex_syslogger": {:git, "https://github.com/slashmili/ex_syslogger.git", "f3963399047af17e038897c69e20d552e6899e1d", [tag: "1.4.0"]}, "excoveralls": {:hex, :excoveralls, "0.11.2", "0c6f2c8db7683b0caa9d490fb8125709c54580b4255ffa7ad35f3264b075a643", [:mix], [{:hackney, "~> 1.0", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm"}, - "fast_sanitize": {:git, "https://git.pleroma.social/pleroma/fast_sanitize.git", "37f55e2bbe6eb44e8a9c4b3831a5ce73a2f6955c", [ref: "37f55e2bbe6eb44e8a9c4b3831a5ce73a2f6955c"]}, + "fast_sanitize": {:git, "https://git.pleroma.social/pleroma/fast_sanitize.git", "d5c47d580a018c4e7f6fadfca63834b9ae28c18c", [ref: "d5c47d580a018c4e7f6fadfca63834b9ae28c18c"]}, "flake_id": {:hex, :flake_id, "0.1.0", "7716b086d2e405d09b647121a166498a0d93d1a623bead243e1f74216079ccb3", [:mix], [{:base62, "~> 1.2", [hex: :base62, repo: "hexpm", optional: false]}, {:ecto, ">= 2.0.0", [hex: :ecto, repo: "hexpm", optional: true]}], "hexpm"}, "floki": {:hex, :floki, "0.23.0", "956ab6dba828c96e732454809fb0bd8d43ce0979b75f34de6322e73d4c917829", [:mix], [{:html_entities, "~> 0.4.0", [hex: :html_entities, repo: "hexpm", optional: false]}], "hexpm"}, "gen_smtp": {:hex, :gen_smtp, "0.15.0", "9f51960c17769b26833b50df0b96123605a8024738b62db747fece14eb2fbfcc", [:rebar3], [], "hexpm"}, @@ -64,9 +64,9 @@ "mock": {:hex, :mock, "0.3.3", "42a433794b1291a9cf1525c6d26b38e039e0d3a360732b5e467bfc77ef26c914", [:mix], [{:meck, "~> 0.8.13", [hex: :meck, repo: "hexpm", optional: false]}], "hexpm"}, "mogrify": {:hex, :mogrify, "0.6.1", "de1b527514f2d95a7bbe9642eb556061afb337e220cf97adbf3a4e6438ed70af", [:mix], [], "hexpm"}, "mox": {:hex, :mox, "0.5.1", "f86bb36026aac1e6f924a4b6d024b05e9adbed5c63e8daa069bd66fb3292165b", [:mix], [], "hexpm"}, - "myhtmlex": {:git, "https://git.pleroma.social/pleroma/myhtmlex.git", "eafbba443260c0055ef2da3918b351b112ff356f", [ref: "eafbba443260c0055ef2da3918b351b112ff356f", submodules: true]}, + "myhtmlex": {:git, "https://git.pleroma.social/pleroma/myhtmlex.git", "99140014f5da4081d2db437e6d769b81c70bf510", [ref: "99140014f5da4081d2db437e6d769b81c70bf510", submodules: true]}, "nimble_parsec": {:hex, :nimble_parsec, "0.5.1", "c90796ecee0289dbb5ad16d3ad06f957b0cd1199769641c961cfe0b97db190e0", [:mix], [], "hexpm"}, - "nodex": {:git, "https://git.pleroma.social/pleroma/nodex", "2927091d96900fb76f6bc897e46a6abb9070ebbd", [ref: "2927091d96900fb76f6bc897e46a6abb9070ebbd"]}, + "nodex": {:git, "https://git.pleroma.social/pleroma/nodex", "cb6730f943cfc6aad674c92161be23a8411f15d1", [ref: "cb6730f943cfc6aad674c92161be23a8411f15d1"]}, "oban": {:hex, :oban, "0.8.1", "4bbf62eb1829f856d69aeb5069ac7036afe07db8221a17de2a9169cc7a58a318", [:mix], [{:ecto_sql, "~> 3.1", [hex: :ecto_sql, repo: "hexpm", optional: false]}, {:jason, "~> 1.1", [hex: :jason, repo: "hexpm", optional: false]}, {:postgrex, "~> 0.14", [hex: :postgrex, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm"}, "parse_trans": {:hex, :parse_trans, "3.3.0", "09765507a3c7590a784615cfd421d101aec25098d50b89d7aa1d66646bc571c1", [:rebar3], [], "hexpm"}, "pbkdf2_elixir": {:hex, :pbkdf2_elixir, "0.12.4", "8dd29ed783f2e12195d7e0a4640effc0a7c37e6537da491f1db01839eee6d053", [:mix], [], "hexpm"}, From 59a149c69a9a6726c7687ba233564936e47fc199 Mon Sep 17 00:00:00 2001 From: Maxim Filippov Date: Thu, 31 Oct 2019 02:25:15 +0300 Subject: [PATCH 057/154] Fix "the call ... will never return" warning --- lib/pleroma/web/admin_api/search.ex | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/pleroma/web/admin_api/search.ex b/lib/pleroma/web/admin_api/search.ex index ed919833e..778cf4c36 100644 --- a/lib/pleroma/web/admin_api/search.ex +++ b/lib/pleroma/web/admin_api/search.ex @@ -18,7 +18,11 @@ defmacro not_empty_string(string) do @spec user(map()) :: {:ok, [User.t()], pos_integer()} def user(params \\ %{}) do - query = User.Query.build(params) |> order_by([u], u.nickname) + query = + params + |> Map.drop([:page, :page_size]) + |> User.Query.build() + |> order_by([u], u.nickname) paginated_query = User.Query.paginate(query, params[:page] || 1, params[:page_size] || @page_size) From 6f9d3d30faece1432068a421fd74d68d93e1d313 Mon Sep 17 00:00:00 2001 From: Maxim Filippov Date: Thu, 31 Oct 2019 02:26:02 +0300 Subject: [PATCH 058/154] AdminAPI: Omit relay user from users list --- lib/pleroma/web/activity_pub/relay.ex | 6 ++++- .../web/admin_api/admin_api_controller.ex | 9 ++++++- .../admin_api/admin_api_controller_test.exs | 27 +++++++++++++++++++ 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/lib/pleroma/web/activity_pub/relay.ex b/lib/pleroma/web/activity_pub/relay.ex index f90d75a8a..fc2619680 100644 --- a/lib/pleroma/web/activity_pub/relay.ex +++ b/lib/pleroma/web/activity_pub/relay.ex @@ -11,13 +11,17 @@ defmodule Pleroma.Web.ActivityPub.Relay do def get_actor do actor = - "#{Pleroma.Web.Endpoint.url()}/relay" + relay_ap_id() |> User.get_or_create_service_actor_by_ap_id() {:ok, actor} = User.set_invisible(actor, true) actor end + def relay_ap_id do + "#{Pleroma.Web.Endpoint.url()}/relay" + end + @spec follow(String.t()) :: {:ok, Activity.t()} | {:error, any()} def follow(target_instance) do with %User{} = local_user <- get_actor(), diff --git a/lib/pleroma/web/admin_api/admin_api_controller.ex b/lib/pleroma/web/admin_api/admin_api_controller.ex index 7ffbb23e7..4533d0114 100644 --- a/lib/pleroma/web/admin_api/admin_api_controller.ex +++ b/lib/pleroma/web/admin_api/admin_api_controller.ex @@ -333,7 +333,8 @@ def list_users(conn, params) do email: params["email"] } - with {:ok, users, count} <- Search.user(Map.merge(search_params, filters)), + with {:ok, users, _count} <- Search.user(Map.merge(search_params, filters)), + {:ok, users, count} <- filter_relay_user(users), do: conn |> json( @@ -345,6 +346,12 @@ def list_users(conn, params) do ) end + defp filter_relay_user(users) do + filtered_users = Enum.reject(users, &(&1.ap_id == Relay.relay_ap_id())) + + {:ok, filtered_users, length(filtered_users)} + end + @filters ~w(local external active deactivated is_admin is_moderator) @spec maybe_parse_filters(String.t()) :: %{required(String.t()) => true} | %{} diff --git a/test/web/admin_api/admin_api_controller_test.exs b/test/web/admin_api/admin_api_controller_test.exs index 22c989892..045c87e95 100644 --- a/test/web/admin_api/admin_api_controller_test.exs +++ b/test/web/admin_api/admin_api_controller_test.exs @@ -13,6 +13,7 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do alias Pleroma.Tests.ObanHelpers alias Pleroma.User alias Pleroma.UserInviteToken + alias Pleroma.Web.ActivityPub.Relay alias Pleroma.Web.CommonAPI alias Pleroma.Web.MediaProxy import Pleroma.Factory @@ -1044,6 +1045,32 @@ test "it works with multiple filters" do ] } end + + test "it omits relay user", %{admin: admin} do + assert %User{} = Relay.get_actor() + + conn = + build_conn() + |> assign(:user, admin) + |> get("/api/pleroma/admin/users") + + assert json_response(conn, 200) == %{ + "count" => 1, + "page_size" => 50, + "users" => [ + %{ + "deactivated" => admin.deactivated, + "id" => admin.id, + "nickname" => admin.nickname, + "roles" => %{"admin" => true, "moderator" => false}, + "local" => true, + "tags" => [], + "avatar" => User.avatar_url(admin) |> MediaProxy.url(), + "display_name" => HTML.strip_tags(admin.name || admin.nickname) + } + ] + } + end end test "PATCH /api/pleroma/admin/users/activate" do From ced9f923270e6b30c4b19a83a8f37516c0e49cf6 Mon Sep 17 00:00:00 2001 From: Maxim Filippov Date: Thu, 31 Oct 2019 15:34:49 +0300 Subject: [PATCH 059/154] Fix count --- lib/pleroma/web/admin_api/admin_api_controller.ex | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/pleroma/web/admin_api/admin_api_controller.ex b/lib/pleroma/web/admin_api/admin_api_controller.ex index 4533d0114..b47618bde 100644 --- a/lib/pleroma/web/admin_api/admin_api_controller.ex +++ b/lib/pleroma/web/admin_api/admin_api_controller.ex @@ -333,8 +333,8 @@ def list_users(conn, params) do email: params["email"] } - with {:ok, users, _count} <- Search.user(Map.merge(search_params, filters)), - {:ok, users, count} <- filter_relay_user(users), + with {:ok, users, count} <- Search.user(Map.merge(search_params, filters)), + {:ok, users, count} <- filter_relay_user(users, count), do: conn |> json( @@ -346,10 +346,15 @@ def list_users(conn, params) do ) end - defp filter_relay_user(users) do - filtered_users = Enum.reject(users, &(&1.ap_id == Relay.relay_ap_id())) + defp filter_relay_user(users, count) do + filtered_users = Enum.reject(users, &relay_user?/1) + count = if Enum.any?(users, &relay_user?/1), do: length(filtered_users), else: count - {:ok, filtered_users, length(filtered_users)} + {:ok, filtered_users, count} + end + + defp relay_user?(user) do + user.ap_id == Relay.relay_ap_id() end @filters ~w(local external active deactivated is_admin is_moderator) From d75934b0d024296654a7eec74abcd65832b6b96b Mon Sep 17 00:00:00 2001 From: Maxim Filippov Date: Fri, 1 Nov 2019 15:14:43 +0300 Subject: [PATCH 060/154] Undo dialyzer fix --- lib/pleroma/web/admin_api/search.ex | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/pleroma/web/admin_api/search.ex b/lib/pleroma/web/admin_api/search.ex index 778cf4c36..ed919833e 100644 --- a/lib/pleroma/web/admin_api/search.ex +++ b/lib/pleroma/web/admin_api/search.ex @@ -18,11 +18,7 @@ defmacro not_empty_string(string) do @spec user(map()) :: {:ok, [User.t()], pos_integer()} def user(params \\ %{}) do - query = - params - |> Map.drop([:page, :page_size]) - |> User.Query.build() - |> order_by([u], u.nickname) + query = User.Query.build(params) |> order_by([u], u.nickname) paginated_query = User.Query.paginate(query, params[:page] || 1, params[:page_size] || @page_size) From 743b622b7b59148525d0f941de3a7c4af7825d22 Mon Sep 17 00:00:00 2001 From: Maxim Filippov Date: Fri, 1 Nov 2019 18:45:47 +0300 Subject: [PATCH 061/154] Force password reset for multiple users --- CHANGELOG.md | 1 + lib/pleroma/moderation_log.ex | 11 +++++++++++ lib/pleroma/web/admin_api/admin_api_controller.ex | 12 +++++++++--- lib/pleroma/web/router.ex | 2 +- test/web/admin_api/admin_api_controller_test.exs | 2 +- 5 files changed, 23 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 51e5424c6..34f46f98a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -67,6 +67,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Mastodon API: Mark the direct conversation as read for the author when they send a new direct message - Deprecated `User.Info` embedded schema (fields moved to `User`) +- Admin API: `PATCH /api/pleroma/admin/users/:nickname/force_password_reset` is now `PATCH /api/pleroma/admin/users/force_password_reset` (accepts `nicknames` array in the request body) ### Fixed - Report emails now include functional links to profiles of remote user accounts diff --git a/lib/pleroma/moderation_log.ex b/lib/pleroma/moderation_log.ex index e8884e6e8..9031102ed 100644 --- a/lib/pleroma/moderation_log.ex +++ b/lib/pleroma/moderation_log.ex @@ -540,6 +540,17 @@ def get_log_entry_message(%ModerationLog{ "@#{actor_nickname} deleted status ##{subject_id}" end + @spec get_log_entry_message(ModerationLog) :: String.t() + def get_log_entry_message(%ModerationLog{ + data: %{ + "actor" => %{"nickname" => actor_nickname}, + "action" => "force_password_reset", + "subject" => subjects + } + }) do + "@#{actor_nickname} force password reset for users: #{users_to_nicknames_string(subjects)}" + end + defp nicknames_to_string(nicknames) do nicknames |> Enum.map(&"@#{&1}") diff --git a/lib/pleroma/web/admin_api/admin_api_controller.ex b/lib/pleroma/web/admin_api/admin_api_controller.ex index 7ffbb23e7..b08011b4c 100644 --- a/lib/pleroma/web/admin_api/admin_api_controller.ex +++ b/lib/pleroma/web/admin_api/admin_api_controller.ex @@ -595,10 +595,16 @@ def get_password_reset(conn, %{"nickname" => nickname}) do end @doc "Force password reset for a given user" - def force_password_reset(conn, %{"nickname" => nickname}) do - (%User{local: true} = user) = User.get_cached_by_nickname(nickname) + def force_password_reset(%{assigns: %{user: admin}} = conn, %{"nicknames" => nicknames}) do + users = nicknames |> Enum.map(&User.get_cached_by_nickname/1) - User.force_password_reset_async(user) + Enum.map(users, &User.force_password_reset_async/1) + + ModerationLog.insert_log(%{ + actor: admin, + subject: users, + action: "force_password_reset" + }) json_response(conn, :no_content, "") end diff --git a/lib/pleroma/web/router.ex b/lib/pleroma/web/router.ex index f69c5c2bc..8fb4aec13 100644 --- a/lib/pleroma/web/router.ex +++ b/lib/pleroma/web/router.ex @@ -171,7 +171,7 @@ defmodule Pleroma.Web.Router do post("/users/email_invite", AdminAPIController, :email_invite) get("/users/:nickname/password_reset", AdminAPIController, :get_password_reset) - patch("/users/:nickname/force_password_reset", AdminAPIController, :force_password_reset) + patch("/users/force_password_reset", AdminAPIController, :force_password_reset) get("/users", AdminAPIController, :list_users) get("/users/:nickname", AdminAPIController, :user_show) diff --git a/test/web/admin_api/admin_api_controller_test.exs b/test/web/admin_api/admin_api_controller_test.exs index 22c989892..920429723 100644 --- a/test/web/admin_api/admin_api_controller_test.exs +++ b/test/web/admin_api/admin_api_controller_test.exs @@ -2538,7 +2538,7 @@ test "sets password_reset_pending to true", %{admin: admin, user: user} do conn = build_conn() |> assign(:user, admin) - |> patch("/api/pleroma/admin/users/#{user.nickname}/force_password_reset") + |> patch("/api/pleroma/admin/users/force_password_reset", %{nicknames: [user.nickname]}) assert json_response(conn, 204) == "" From 1b83a0694a19e279d155dde2c915df3583f12170 Mon Sep 17 00:00:00 2001 From: Maxim Filippov Date: Fri, 1 Nov 2019 19:13:29 +0300 Subject: [PATCH 062/154] Fix moderation log crash --- lib/pleroma/moderation_log.ex | 76 +++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/lib/pleroma/moderation_log.ex b/lib/pleroma/moderation_log.ex index e8884e6e8..9dc4a94c9 100644 --- a/lib/pleroma/moderation_log.ex +++ b/lib/pleroma/moderation_log.ex @@ -369,6 +369,24 @@ def get_log_entry_message(%ModerationLog{ "@#{actor_nickname} created users: #{users_to_nicknames_string(subjects)}" end + @spec get_log_entry_message(ModerationLog) :: String.t() + def get_log_entry_message(%ModerationLog{ + data: %{ + "actor" => %{"nickname" => actor_nickname}, + "action" => "activate", + "subject" => user + } + }) + when is_map(user) do + get_log_entry_message(%ModerationLog{ + data: %{ + "actor" => %{"nickname" => actor_nickname}, + "action" => "activate", + "subject" => [user] + } + }) + end + @spec get_log_entry_message(ModerationLog) :: String.t() def get_log_entry_message(%ModerationLog{ data: %{ @@ -380,6 +398,24 @@ def get_log_entry_message(%ModerationLog{ "@#{actor_nickname} activated users: #{users_to_nicknames_string(users)}" end + @spec get_log_entry_message(ModerationLog) :: String.t() + def get_log_entry_message(%ModerationLog{ + data: %{ + "actor" => %{"nickname" => actor_nickname}, + "action" => "deactivate", + "subject" => user + } + }) + when is_map(user) do + get_log_entry_message(%ModerationLog{ + data: %{ + "actor" => %{"nickname" => actor_nickname}, + "action" => "deactivate", + "subject" => [user] + } + }) + end + @spec get_log_entry_message(ModerationLog) :: String.t() def get_log_entry_message(%ModerationLog{ data: %{ @@ -419,6 +455,26 @@ def get_log_entry_message(%ModerationLog{ "@#{actor_nickname} removed tags: #{tags_string} from users: #{nicknames_to_string(nicknames)}" end + @spec get_log_entry_message(ModerationLog) :: String.t() + def get_log_entry_message(%ModerationLog{ + data: %{ + "actor" => %{"nickname" => actor_nickname}, + "action" => "grant", + "subject" => user, + "permission" => permission + } + }) + when is_map(user) do + get_log_entry_message(%ModerationLog{ + data: %{ + "actor" => %{"nickname" => actor_nickname}, + "action" => "grant", + "subject" => [user], + "permission" => permission + } + }) + end + @spec get_log_entry_message(ModerationLog) :: String.t() def get_log_entry_message(%ModerationLog{ data: %{ @@ -431,6 +487,26 @@ def get_log_entry_message(%ModerationLog{ "@#{actor_nickname} made #{users_to_nicknames_string(users)} #{permission}" end + @spec get_log_entry_message(ModerationLog) :: String.t() + def get_log_entry_message(%ModerationLog{ + data: %{ + "actor" => %{"nickname" => actor_nickname}, + "action" => "revoke", + "subject" => user, + "permission" => permission + } + }) + when is_map(user) do + get_log_entry_message(%ModerationLog{ + data: %{ + "actor" => %{"nickname" => actor_nickname}, + "action" => "revoke", + "subject" => [user], + "permission" => permission + } + }) + end + @spec get_log_entry_message(ModerationLog) :: String.t() def get_log_entry_message(%ModerationLog{ data: %{ From 10e9ba6340e1f26dcb818ad2e06fdab20df82e4b Mon Sep 17 00:00:00 2001 From: Maxim Filippov Date: Fri, 1 Nov 2019 17:25:41 +0000 Subject: [PATCH 063/154] Apply suggestion to CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 34f46f98a..989e0974a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -67,7 +67,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Mastodon API: Mark the direct conversation as read for the author when they send a new direct message - Deprecated `User.Info` embedded schema (fields moved to `User`) -- Admin API: `PATCH /api/pleroma/admin/users/:nickname/force_password_reset` is now `PATCH /api/pleroma/admin/users/force_password_reset` (accepts `nicknames` array in the request body) +- **Breaking** Admin API: `PATCH /api/pleroma/admin/users/:nickname/force_password_reset` is now `PATCH /api/pleroma/admin/users/force_password_reset` (accepts `nicknames` array in the request body) ### Fixed - Report emails now include functional links to profiles of remote user accounts From ab5c8ec9fac8045cd5a3f25526f302bc9249e1bf Mon Sep 17 00:00:00 2001 From: Maxim Filippov Date: Fri, 1 Nov 2019 20:26:52 +0300 Subject: [PATCH 064/154] Update docs --- docs/API/admin_api.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/API/admin_api.md b/docs/API/admin_api.md index e64ae6429..c042b08ac 100644 --- a/docs/API/admin_api.md +++ b/docs/API/admin_api.md @@ -392,13 +392,13 @@ Note: Available `:permission_group` is currently moderator and admin. 404 is ret } ``` - -## `/api/pleroma/admin/users/:nickname/force_password_reset` +## `/api/pleroma/admin/users/force_password_reset` ### Force passord reset for a user with a given nickname - Methods: `PATCH` -- Params: none +- Params: + - `nicknames` - Response: none (code `204`) ## `/api/pleroma/admin/reports` From 55ef88ef95ecda94ea416bd3a8492f992488ea83 Mon Sep 17 00:00:00 2001 From: rinpatch Date: Fri, 1 Nov 2019 20:58:24 +0300 Subject: [PATCH 065/154] Bump fast_sanitize version --- mix.exs | 2 +- mix.lock | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mix.exs b/mix.exs index 66cea7b89..f3ef8d955 100644 --- a/mix.exs +++ b/mix.exs @@ -110,7 +110,7 @@ defp deps do {:trailing_format_plug, "~> 0.0.7"}, {:fast_sanitize, git: "https://git.pleroma.social/pleroma/fast_sanitize.git", - ref: "d5c47d580a018c4e7f6fadfca63834b9ae28c18c"}, + ref: "cb92cc6f63b183863f5cecb0c740c34642da5216"}, {:html_entities, "~> 0.4"}, {:phoenix_html, "~> 2.10"}, {:calendar, "~> 0.17.4"}, diff --git a/mix.lock b/mix.lock index 802cb2959..c867a9605 100644 --- a/mix.lock +++ b/mix.lock @@ -36,7 +36,7 @@ "ex_rated": {:hex, :ex_rated, "1.3.3", "30ecbdabe91f7eaa9d37fa4e81c85ba420f371babeb9d1910adbcd79ec798d27", [:mix], [{:ex2ms, "~> 1.5", [hex: :ex2ms, repo: "hexpm", optional: false]}], "hexpm"}, "ex_syslogger": {:git, "https://github.com/slashmili/ex_syslogger.git", "f3963399047af17e038897c69e20d552e6899e1d", [tag: "1.4.0"]}, "excoveralls": {:hex, :excoveralls, "0.11.2", "0c6f2c8db7683b0caa9d490fb8125709c54580b4255ffa7ad35f3264b075a643", [:mix], [{:hackney, "~> 1.0", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm"}, - "fast_sanitize": {:git, "https://git.pleroma.social/pleroma/fast_sanitize.git", "d5c47d580a018c4e7f6fadfca63834b9ae28c18c", [ref: "d5c47d580a018c4e7f6fadfca63834b9ae28c18c"]}, + "fast_sanitize": {:git, "https://git.pleroma.social/pleroma/fast_sanitize.git", "cb92cc6f63b183863f5cecb0c740c34642da5216", [ref: "cb92cc6f63b183863f5cecb0c740c34642da5216"]}, "flake_id": {:hex, :flake_id, "0.1.0", "7716b086d2e405d09b647121a166498a0d93d1a623bead243e1f74216079ccb3", [:mix], [{:base62, "~> 1.2", [hex: :base62, repo: "hexpm", optional: false]}, {:ecto, ">= 2.0.0", [hex: :ecto, repo: "hexpm", optional: true]}], "hexpm"}, "floki": {:hex, :floki, "0.23.0", "956ab6dba828c96e732454809fb0bd8d43ce0979b75f34de6322e73d4c917829", [:mix], [{:html_entities, "~> 0.4.0", [hex: :html_entities, repo: "hexpm", optional: false]}], "hexpm"}, "gen_smtp": {:hex, :gen_smtp, "0.15.0", "9f51960c17769b26833b50df0b96123605a8024738b62db747fece14eb2fbfcc", [:rebar3], [], "hexpm"}, @@ -64,7 +64,7 @@ "mock": {:hex, :mock, "0.3.3", "42a433794b1291a9cf1525c6d26b38e039e0d3a360732b5e467bfc77ef26c914", [:mix], [{:meck, "~> 0.8.13", [hex: :meck, repo: "hexpm", optional: false]}], "hexpm"}, "mogrify": {:hex, :mogrify, "0.6.1", "de1b527514f2d95a7bbe9642eb556061afb337e220cf97adbf3a4e6438ed70af", [:mix], [], "hexpm"}, "mox": {:hex, :mox, "0.5.1", "f86bb36026aac1e6f924a4b6d024b05e9adbed5c63e8daa069bd66fb3292165b", [:mix], [], "hexpm"}, - "myhtmlex": {:git, "https://git.pleroma.social/pleroma/myhtmlex.git", "99140014f5da4081d2db437e6d769b81c70bf510", [ref: "99140014f5da4081d2db437e6d769b81c70bf510", submodules: true]}, + "myhtmlex": {:git, "https://git.pleroma.social/pleroma/myhtmlex.git", "4288bda52c53a2d416afa09e1007a881eb2dafab", [ref: "4288bda52c53a2d416afa09e1007a881eb2dafab", submodules: true]}, "nimble_parsec": {:hex, :nimble_parsec, "0.5.1", "c90796ecee0289dbb5ad16d3ad06f957b0cd1199769641c961cfe0b97db190e0", [:mix], [], "hexpm"}, "nodex": {:git, "https://git.pleroma.social/pleroma/nodex", "cb6730f943cfc6aad674c92161be23a8411f15d1", [ref: "cb6730f943cfc6aad674c92161be23a8411f15d1"]}, "oban": {:hex, :oban, "0.8.1", "4bbf62eb1829f856d69aeb5069ac7036afe07db8221a17de2a9169cc7a58a318", [:mix], [{:ecto_sql, "~> 3.1", [hex: :ecto_sql, repo: "hexpm", optional: false]}, {:jason, "~> 1.1", [hex: :jason, repo: "hexpm", optional: false]}, {:postgrex, "~> 0.14", [hex: :postgrex, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm"}, From 4bf942583fdae27813f4af1f901c78eaff391b76 Mon Sep 17 00:00:00 2001 From: Ariadne Conill Date: Sun, 3 Nov 2019 09:05:12 -0600 Subject: [PATCH 066/154] streamer: use direct object for filter checks when there is no valid child object in an activity We call Object.normalize/1 to get the child object for situations like Announce. However, the check is flawed and immediately fails if Object.normalize/1 fails. Instead, we should use the activity itself in those cases to allow activities which never have a child object to pass through the filter. Closes #1291 --- lib/pleroma/web/streamer/worker.ex | 2 +- test/web/streamer/streamer_test.exs | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/pleroma/web/streamer/worker.ex b/lib/pleroma/web/streamer/worker.ex index c2ee9e1f5..33b24840d 100644 --- a/lib/pleroma/web/streamer/worker.ex +++ b/lib/pleroma/web/streamer/worker.ex @@ -136,7 +136,7 @@ defp should_send?(%User{} = user, %Activity{} = item) do recipients = MapSet.new(item.recipients) domain_blocks = Pleroma.Web.ActivityPub.MRF.subdomains_regex(user.domain_blocks) - with parent when not is_nil(parent) <- Object.normalize(item), + with parent <- Object.normalize(item) || item, true <- Enum.all?([blocks, mutes, reblog_mutes], &(item.actor not in &1)), true <- Enum.all?([blocks, mutes], &(parent.data["actor"] not in &1)), true <- MapSet.disjoint?(recipients, recipient_blocks), diff --git a/test/web/streamer/streamer_test.exs b/test/web/streamer/streamer_test.exs index cb1015171..d6968f4d0 100644 --- a/test/web/streamer/streamer_test.exs +++ b/test/web/streamer/streamer_test.exs @@ -110,6 +110,24 @@ test "it doesn't send notify to the 'user:notification' stream' when a domain is Streamer.stream("user:notification", notif) Task.await(task) end + + test "it sends follow activities to the 'user:notification' stream", %{ + user: user + } do + user2 = insert(:user) + task = Task.async(fn -> assert_receive {:text, _}, 4_000 end) + + Streamer.add_socket( + "user:notification", + %{transport_pid: task.pid, assigns: %{user: user}} + ) + + {:ok, _follower, _followed, _activity} = CommonAPI.follow(user2, user) + + # We don't directly pipe the notification to the streamer as it's already + # generated as a side effect of CommonAPI.follow(). + Task.await(task) + end end test "it sends to public" do From f42f30087049bb657ebbb8cd8511b1c6888e1ccd Mon Sep 17 00:00:00 2001 From: Ariadne Conill Date: Sun, 3 Nov 2019 15:41:30 -0600 Subject: [PATCH 067/154] update fast sanitize dependency --- mix.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mix.exs b/mix.exs index f3ef8d955..f3db83556 100644 --- a/mix.exs +++ b/mix.exs @@ -110,7 +110,7 @@ defp deps do {:trailing_format_plug, "~> 0.0.7"}, {:fast_sanitize, git: "https://git.pleroma.social/pleroma/fast_sanitize.git", - ref: "cb92cc6f63b183863f5cecb0c740c34642da5216"}, + ref: "757e816bbd2cdd3f8357d02a3ed11230e9ff80f2"}, {:html_entities, "~> 0.4"}, {:phoenix_html, "~> 2.10"}, {:calendar, "~> 0.17.4"}, From 0c3125861619f164015ee0cf0bdf293d49804926 Mon Sep 17 00:00:00 2001 From: lain Date: Mon, 4 Nov 2019 14:36:54 +0100 Subject: [PATCH 068/154] User: Don't pull remote users follower count immediately after deactivating. The other instance doesn't necessarily know that anything changed yet, and it will be fixed up at the next user pull anyway. Closes #1369 --- lib/pleroma/user.ex | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index 40171620e..f8c2db1e1 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -1095,7 +1095,12 @@ def deactivate(users, status) when is_list(users) do def deactivate(%User{} = user, status) do with {:ok, user} <- set_activation_status(user, status) do Enum.each(get_followers(user), &invalidate_cache/1) - Enum.each(get_friends(user), &update_follower_count/1) + + # Only update local user counts, remote will be update during the next pull. + user + |> get_friends() + |> Enum.filter(& &1.local) + |> Enum.each(&update_follower_count/1) {:ok, user} end From 203d9812f0d14a0edd80871a1046a7eeaea6f606 Mon Sep 17 00:00:00 2001 From: Ariadne Conill Date: Mon, 4 Nov 2019 08:38:14 -0600 Subject: [PATCH 069/154] mix: update fast_sanitize dependency to 1af67547 --- mix.exs | 2 +- mix.lock | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mix.exs b/mix.exs index f3db83556..1bc4cec2f 100644 --- a/mix.exs +++ b/mix.exs @@ -110,7 +110,7 @@ defp deps do {:trailing_format_plug, "~> 0.0.7"}, {:fast_sanitize, git: "https://git.pleroma.social/pleroma/fast_sanitize.git", - ref: "757e816bbd2cdd3f8357d02a3ed11230e9ff80f2"}, + ref: "1af67547a02a104e26c99d03012383e8643bc4c2"}, {:html_entities, "~> 0.4"}, {:phoenix_html, "~> 2.10"}, {:calendar, "~> 0.17.4"}, diff --git a/mix.lock b/mix.lock index c867a9605..cfc3b84a8 100644 --- a/mix.lock +++ b/mix.lock @@ -36,7 +36,7 @@ "ex_rated": {:hex, :ex_rated, "1.3.3", "30ecbdabe91f7eaa9d37fa4e81c85ba420f371babeb9d1910adbcd79ec798d27", [:mix], [{:ex2ms, "~> 1.5", [hex: :ex2ms, repo: "hexpm", optional: false]}], "hexpm"}, "ex_syslogger": {:git, "https://github.com/slashmili/ex_syslogger.git", "f3963399047af17e038897c69e20d552e6899e1d", [tag: "1.4.0"]}, "excoveralls": {:hex, :excoveralls, "0.11.2", "0c6f2c8db7683b0caa9d490fb8125709c54580b4255ffa7ad35f3264b075a643", [:mix], [{:hackney, "~> 1.0", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm"}, - "fast_sanitize": {:git, "https://git.pleroma.social/pleroma/fast_sanitize.git", "cb92cc6f63b183863f5cecb0c740c34642da5216", [ref: "cb92cc6f63b183863f5cecb0c740c34642da5216"]}, + "fast_sanitize": {:git, "https://git.pleroma.social/pleroma/fast_sanitize.git", "1af67547a02a104e26c99d03012383e8643bc4c2", [ref: "1af67547a02a104e26c99d03012383e8643bc4c2"]}, "flake_id": {:hex, :flake_id, "0.1.0", "7716b086d2e405d09b647121a166498a0d93d1a623bead243e1f74216079ccb3", [:mix], [{:base62, "~> 1.2", [hex: :base62, repo: "hexpm", optional: false]}, {:ecto, ">= 2.0.0", [hex: :ecto, repo: "hexpm", optional: true]}], "hexpm"}, "floki": {:hex, :floki, "0.23.0", "956ab6dba828c96e732454809fb0bd8d43ce0979b75f34de6322e73d4c917829", [:mix], [{:html_entities, "~> 0.4.0", [hex: :html_entities, repo: "hexpm", optional: false]}], "hexpm"}, "gen_smtp": {:hex, :gen_smtp, "0.15.0", "9f51960c17769b26833b50df0b96123605a8024738b62db747fece14eb2fbfcc", [:rebar3], [], "hexpm"}, @@ -64,7 +64,7 @@ "mock": {:hex, :mock, "0.3.3", "42a433794b1291a9cf1525c6d26b38e039e0d3a360732b5e467bfc77ef26c914", [:mix], [{:meck, "~> 0.8.13", [hex: :meck, repo: "hexpm", optional: false]}], "hexpm"}, "mogrify": {:hex, :mogrify, "0.6.1", "de1b527514f2d95a7bbe9642eb556061afb337e220cf97adbf3a4e6438ed70af", [:mix], [], "hexpm"}, "mox": {:hex, :mox, "0.5.1", "f86bb36026aac1e6f924a4b6d024b05e9adbed5c63e8daa069bd66fb3292165b", [:mix], [], "hexpm"}, - "myhtmlex": {:git, "https://git.pleroma.social/pleroma/myhtmlex.git", "4288bda52c53a2d416afa09e1007a881eb2dafab", [ref: "4288bda52c53a2d416afa09e1007a881eb2dafab", submodules: true]}, + "myhtmlex": {:git, "https://git.pleroma.social/pleroma/myhtmlex.git", "ad0097e2f61d4953bfef20fb6abddf23b87111e6", [ref: "ad0097e2f61d4953bfef20fb6abddf23b87111e6", submodules: true]}, "nimble_parsec": {:hex, :nimble_parsec, "0.5.1", "c90796ecee0289dbb5ad16d3ad06f957b0cd1199769641c961cfe0b97db190e0", [:mix], [], "hexpm"}, "nodex": {:git, "https://git.pleroma.social/pleroma/nodex", "cb6730f943cfc6aad674c92161be23a8411f15d1", [ref: "cb6730f943cfc6aad674c92161be23a8411f15d1"]}, "oban": {:hex, :oban, "0.8.1", "4bbf62eb1829f856d69aeb5069ac7036afe07db8221a17de2a9169cc7a58a318", [:mix], [{:ecto_sql, "~> 3.1", [hex: :ecto_sql, repo: "hexpm", optional: false]}, {:jason, "~> 1.1", [hex: :jason, repo: "hexpm", optional: false]}, {:postgrex, "~> 0.14", [hex: :postgrex, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm"}, From 5271bbcf11d7182c25c8ca06460823e00920e80d Mon Sep 17 00:00:00 2001 From: Steven Fuchs Date: Mon, 4 Nov 2019 15:18:32 +0000 Subject: [PATCH 070/154] add missing tesla mocks --- lib/pleroma/web/rel_me.ex | 14 +++++++------- test/support/http_request_mock.ex | 28 ++++++++++++++++++++++++++++ test/web/rel_me_test.exs | 4 +++- 3 files changed, 38 insertions(+), 8 deletions(-) diff --git a/lib/pleroma/web/rel_me.ex b/lib/pleroma/web/rel_me.ex index d376e2069..16b1a53d2 100644 --- a/lib/pleroma/web/rel_me.ex +++ b/lib/pleroma/web/rel_me.ex @@ -25,13 +25,13 @@ def parse(url) when is_binary(url) do def parse(_), do: {:error, "No URL provided"} defp parse_url(url) do - {:ok, %Tesla.Env{body: html}} = Pleroma.HTTP.get(url, [], adapter: @hackney_options) - - data = - Floki.attribute(html, "link[rel~=me]", "href") ++ - Floki.attribute(html, "a[rel~=me]", "href") - - {:ok, data} + with {:ok, %Tesla.Env{body: html, status: status}} when status in 200..299 <- + Pleroma.HTTP.get(url, [], adapter: @hackney_options), + data <- + Floki.attribute(html, "link[rel~=me]", "href") ++ + Floki.attribute(html, "a[rel~=me]", "href") do + {:ok, data} + end rescue e -> {:error, "Parsing error: #{inspect(e)}"} end diff --git a/test/support/http_request_mock.ex b/test/support/http_request_mock.ex index eba22c40b..965335e96 100644 --- a/test/support/http_request_mock.ex +++ b/test/support/http_request_mock.ex @@ -1183,6 +1183,30 @@ def get("https://mstdn.jp/.well-known/webfinger?resource=acct:kpherox@mstdn.jp", }} end + def get("https://10.111.10.1/notice/9kCP7V", _, _, _) do + {:ok, %Tesla.Env{status: 200, body: ""}} + end + + def get("https://172.16.32.40/notice/9kCP7V", _, _, _) do + {:ok, %Tesla.Env{status: 200, body: ""}} + end + + def get("https://192.168.10.40/notice/9kCP7V", _, _, _) do + {:ok, %Tesla.Env{status: 200, body: ""}} + end + + def get("https://www.patreon.com/posts/mastodon-2-9-and-28121681", _, _, _) do + {:ok, %Tesla.Env{status: 200, body: ""}} + end + + def get("http://mastodon.example.org/@admin/99541947525187367", _, _, _) do + {:ok, %Tesla.Env{status: 200, body: File.read!("test/fixtures/mastodon-post-activity.json")}} + end + + def get("https://info.pleroma.site/activity4.json", _, _, _) do + {:ok, %Tesla.Env{status: 500, body: "Error occurred"}} + end + def get("http://example.com/rel_me/anchor", _, _, _) do {:ok, %Tesla.Env{status: 200, body: File.read!("test/fixtures/rel_me_anchor.html")}} end @@ -1215,6 +1239,10 @@ def get("https://patch.cx/users/rin", _, _, _) do {:ok, %Tesla.Env{status: 200, body: File.read!("test/fixtures/tesla_mock/rin.json")}} end + def get("http://example.com/rel_me/error", _, _, _) do + {:ok, %Tesla.Env{status: 404, body: ""}} + end + def get(url, query, body, headers) do {:error, "Mock response not implemented for GET #{inspect(url)}, #{query}, #{inspect(body)}, #{ diff --git a/test/web/rel_me_test.exs b/test/web/rel_me_test.exs index 2251fed16..77b5d5dc6 100644 --- a/test/web/rel_me_test.exs +++ b/test/web/rel_me_test.exs @@ -14,7 +14,9 @@ test "parse/1" do hrefs = ["https://social.example.org/users/lain"] assert Pleroma.Web.RelMe.parse("http://example.com/rel_me/null") == {:ok, []} - assert {:error, _} = Pleroma.Web.RelMe.parse("http://example.com/rel_me/error") + + assert {:ok, %Tesla.Env{status: 404}} = + Pleroma.Web.RelMe.parse("http://example.com/rel_me/error") assert Pleroma.Web.RelMe.parse("http://example.com/rel_me/link") == {:ok, hrefs} assert Pleroma.Web.RelMe.parse("http://example.com/rel_me/anchor") == {:ok, hrefs} From ed29be24cbdc029614557a5289a9b8c8facddf8e Mon Sep 17 00:00:00 2001 From: eugenijm Date: Thu, 31 Oct 2019 03:44:27 +0300 Subject: [PATCH 071/154] Mastodon API, streaming: Add `pleroma.direct_conversation_id` to the `conversation` stream event payload. --- CHANGELOG.md | 1 + .../mastodon_api/views/conversation_view.ex | 6 ++++- .../web/mastodon_api/views/status_view.ex | 6 ++++- .../views/conversation_view_test.exs | 1 + .../mastodon_api/views/status_view_test.exs | 25 +++++++++++++++++-- test/web/streamer/streamer_test.exs | 12 +++++++-- 6 files changed, 45 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 00dd62e24..77edf7bf0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Mastodon API: Add `pleroma.direct_conversation_id` to the status endpoint (`GET /api/v1/statuses/:id`) - Mastodon API: `pleroma.thread_muted` to the Status entity - Mastodon API: Mark the direct conversation as read for the author when they send a new direct message +- Mastodon API, streaming: Add `pleroma.direct_conversation_id` to the `conversation` stream event payload. ### Added diff --git a/lib/pleroma/web/mastodon_api/views/conversation_view.ex b/lib/pleroma/web/mastodon_api/views/conversation_view.ex index e9d2735b3..c5998e661 100644 --- a/lib/pleroma/web/mastodon_api/views/conversation_view.ex +++ b/lib/pleroma/web/mastodon_api/views/conversation_view.ex @@ -34,7 +34,11 @@ def render("participation.json", %{participation: participation, for: user}) do id: participation.id |> to_string(), accounts: render(AccountView, "index.json", users: users, as: :user), unread: !participation.read, - last_status: render(StatusView, "show.json", activity: activity, for: user) + last_status: + render(StatusView, "show.json", + activity: activity, + direct_conversation_id: participation.id + ) } 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 b785ca9d4..baff54151 100644 --- a/lib/pleroma/web/mastodon_api/views/status_view.ex +++ b/lib/pleroma/web/mastodon_api/views/status_view.ex @@ -243,7 +243,8 @@ def render("show.json", %{activity: %{data: %{"object" => _object}} = activity} end direct_conversation_id = - with {_, true} <- {:include_id, opts[:with_direct_conversation_id]}, + with {_, nil} <- {:direct_conversation_id, opts[:direct_conversation_id]}, + {_, true} <- {:include_id, opts[:with_direct_conversation_id]}, {_, %User{} = for_user} <- {:for_user, opts[:for]}, %{data: %{"context" => context}} when is_binary(context) <- activity, %Conversation{} = conversation <- Conversation.get_for_ap_id(context), @@ -251,6 +252,9 @@ def render("show.json", %{activity: %{data: %{"object" => _object}} = activity} Participation.for_user_and_conversation(for_user, conversation) do participation_id else + {:direct_conversation_id, participation_id} when is_integer(participation_id) -> + participation_id + _e -> nil end diff --git a/test/web/mastodon_api/views/conversation_view_test.exs b/test/web/mastodon_api/views/conversation_view_test.exs index a2a880705..6ed22597d 100644 --- a/test/web/mastodon_api/views/conversation_view_test.exs +++ b/test/web/mastodon_api/views/conversation_view_test.exs @@ -30,5 +30,6 @@ test "represents a Mastodon Conversation entity" do assert [account] = conversation.accounts assert account.id == other_user.id + assert conversation.last_status.pleroma.direct_conversation_id == participation.id end end diff --git a/test/web/mastodon_api/views/status_view_test.exs b/test/web/mastodon_api/views/status_view_test.exs index 7526f2f27..d46ecc646 100644 --- a/test/web/mastodon_api/views/status_view_test.exs +++ b/test/web/mastodon_api/views/status_view_test.exs @@ -7,6 +7,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do alias Pleroma.Activity alias Pleroma.Bookmark + alias Pleroma.Conversation.Participation alias Pleroma.HTML alias Pleroma.Object alias Pleroma.Repo @@ -23,10 +24,11 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do :ok end - test "returns the direct conversation id when given the `with_conversation_id` option" do + test "loads and returns the direct conversation id when given the `with_direct_conversation_id` option" do user = insert(:user) {:ok, activity} = CommonAPI.post(user, %{"status" => "Hey @shp!", "visibility" => "direct"}) + [participation] = Participation.for_user(user) status = StatusView.render("show.json", @@ -35,7 +37,26 @@ test "returns the direct conversation id when given the `with_conversation_id` o for: user ) - assert status[:pleroma][:direct_conversation_id] + assert status[:pleroma][:direct_conversation_id] == participation.id + + status = StatusView.render("show.json", activity: activity, for: user) + assert status[:pleroma][:direct_conversation_id] == nil + end + + test "returns the direct conversation id when given the `direct_conversation_id` option" do + user = insert(:user) + + {:ok, activity} = CommonAPI.post(user, %{"status" => "Hey @shp!", "visibility" => "direct"}) + [participation] = Participation.for_user(user) + + status = + StatusView.render("show.json", + activity: activity, + direct_conversation_id: participation.id, + for: user + ) + + assert status[:pleroma][:direct_conversation_id] == participation.id end test "returns a temporary ap_id based user for activities missing db users" do diff --git a/test/web/streamer/streamer_test.exs b/test/web/streamer/streamer_test.exs index d6968f4d0..80a7541b2 100644 --- a/test/web/streamer/streamer_test.exs +++ b/test/web/streamer/streamer_test.exs @@ -7,6 +7,7 @@ defmodule Pleroma.Web.StreamerTest do import Pleroma.Factory + alias Pleroma.Conversation.Participation alias Pleroma.List alias Pleroma.User alias Pleroma.Web.CommonAPI @@ -481,7 +482,14 @@ test "it sends conversation update to the 'direct' stream", %{} do task = Task.async(fn -> - assert_receive {:text, _received_event}, 4_000 + assert_receive {:text, received_event}, 4_000 + + assert %{"event" => "conversation", "payload" => received_payload} = + Jason.decode!(received_event) + + assert %{"last_status" => last_status} = Jason.decode!(received_payload) + [participation] = Participation.for_user(user) + assert last_status["pleroma"]["direct_conversation_id"] == participation.id end) Streamer.add_socket( @@ -498,7 +506,7 @@ test "it sends conversation update to the 'direct' stream", %{} do Task.await(task) end - test "it doesn't send conversation update to the 'direct' streamj when the last message in the conversation is deleted" do + test "it doesn't send conversation update to the 'direct' stream when the last message in the conversation is deleted" do user = insert(:user) another_user = insert(:user) From 4e535209172bb5460353fe011c06d127cfaa5847 Mon Sep 17 00:00:00 2001 From: lain Date: Mon, 4 Nov 2019 16:57:41 +0100 Subject: [PATCH 072/154] User Search: Remove superfluous setweight and random test. The test tested for a behavior that isn't actually enforced anymore. --- lib/pleroma/user/search.ex | 12 +----------- test/user_search_test.exs | 7 ------- 2 files changed, 1 insertion(+), 18 deletions(-) diff --git a/lib/pleroma/user/search.ex b/lib/pleroma/user/search.ex index bab8d92e2..09664db76 100644 --- a/lib/pleroma/user/search.ex +++ b/lib/pleroma/user/search.ex @@ -54,15 +54,7 @@ defp search_query(query_string, for_user, following) do |> maybe_restrict_local(for_user) end - @nickname_regex ~r/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~\-@]+$/ defp fts_search(query, query_string) do - {nickname_weight, name_weight} = - if String.match?(query_string, @nickname_regex) do - {"A", "B"} - else - {"B", "A"} - end - query_string = to_tsquery(query_string) from( @@ -70,12 +62,10 @@ defp fts_search(query, query_string) do where: fragment( """ - (setweight(to_tsvector('simple', ?), ?) || setweight(to_tsvector('simple', ?), ?)) @@ to_tsquery('simple', ?) + (to_tsvector('simple', ?) || to_tsvector('simple', ?)) @@ to_tsquery('simple', ?) """, u.name, - ^name_weight, u.nickname, - ^nickname_weight, ^query_string ) ) diff --git a/test/user_search_test.exs b/test/user_search_test.exs index 78a02d536..721af1e5b 100644 --- a/test/user_search_test.exs +++ b/test/user_search_test.exs @@ -51,13 +51,6 @@ test "finds a user by full or partial name" do end) end - test "finds users, preferring nickname matches over name matches" do - u1 = insert(:user, %{name: "lain", nickname: "nick1"}) - u2 = insert(:user, %{nickname: "lain", name: "nick1"}) - - assert [u2.id, u1.id] == Enum.map(User.search("lain"), & &1.id) - end - test "finds users, considering density of matched tokens" do u1 = insert(:user, %{name: "Bar Bar plus Word Word"}) u2 = insert(:user, %{name: "Word Word Bar Bar Bar"}) From 9d3b12a6588846978f16be4423f43f64efef2f66 Mon Sep 17 00:00:00 2001 From: rinpatch Date: Tue, 5 Nov 2019 12:37:25 +0300 Subject: [PATCH 073/154] Bump HtmlEntities to 0.5 This release brings a major performance imrovement, see https://github.com/martinsvalin/html_entities/pull/17 --- mix.exs | 2 +- mix.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mix.exs b/mix.exs index 1bc4cec2f..0a3a03a61 100644 --- a/mix.exs +++ b/mix.exs @@ -111,7 +111,7 @@ defp deps do {:fast_sanitize, git: "https://git.pleroma.social/pleroma/fast_sanitize.git", ref: "1af67547a02a104e26c99d03012383e8643bc4c2"}, - {:html_entities, "~> 0.4"}, + {:html_entities, "~> 0.5", override: true}, {:phoenix_html, "~> 2.10"}, {:calendar, "~> 0.17.4"}, {:cachex, "~> 3.0.2"}, diff --git a/mix.lock b/mix.lock index cfc3b84a8..082665c3c 100644 --- a/mix.lock +++ b/mix.lock @@ -44,7 +44,7 @@ "gen_state_machine": {:hex, :gen_state_machine, "2.0.5", "9ac15ec6e66acac994cc442dcc2c6f9796cf380ec4b08267223014be1c728a95", [:mix], [], "hexpm"}, "gettext": {:hex, :gettext, "0.17.1", "8baab33482df4907b3eae22f719da492cee3981a26e649b9c2be1c0192616962", [:mix], [], "hexpm"}, "hackney": {:hex, :hackney, "1.15.2", "07e33c794f8f8964ee86cebec1a8ed88db5070e52e904b8f12209773c1036085", [:rebar3], [{:certifi, "2.5.1", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "6.0.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "~>1.1", [hex: :mimerl, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.5", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm"}, - "html_entities": {:hex, :html_entities, "0.4.0", "f2fee876858cf6aaa9db608820a3209e45a087c5177332799592142b50e89a6b", [:mix], [], "hexpm"}, + "html_entities": {:hex, :html_entities, "0.5.0", "40f5c5b9cbe23073b48a4e69c67b6c11974f623a76165e2b92d098c0e88ccb1d", [:mix], [], "hexpm"}, "html_sanitize_ex": {:hex, :html_sanitize_ex, "1.3.0", "f005ad692b717691203f940c686208aa3d8ffd9dd4bb3699240096a51fa9564e", [:mix], [{:mochiweb, "~> 2.15", [hex: :mochiweb, repo: "hexpm", optional: false]}], "hexpm"}, "http_signatures": {:git, "https://git.pleroma.social/pleroma/http_signatures.git", "293d77bb6f4a67ac8bde1428735c3b42f22cbb30", [ref: "293d77bb6f4a67ac8bde1428735c3b42f22cbb30"]}, "httpoison": {:hex, :httpoison, "1.6.1", "2ce5bf6e535cd0ab02e905ba8c276580bab80052c5c549f53ddea52d72e81f33", [:mix], [{:hackney, "~> 1.15 and >= 1.15.2", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm"}, From e1fc6cb78f07653300965d212d9c5ece9f5c3de0 Mon Sep 17 00:00:00 2001 From: AkiraFukushima Date: Tue, 5 Nov 2019 23:52:47 +0900 Subject: [PATCH 074/154] Check client and token in GET /oauth/authorize --- lib/pleroma/web/oauth/oauth_controller.ex | 18 +++++++++++++++++- test/web/oauth/oauth_controller_test.exs | 23 +++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/lib/pleroma/web/oauth/oauth_controller.ex b/lib/pleroma/web/oauth/oauth_controller.ex index fe71aca8c..6fba9f968 100644 --- a/lib/pleroma/web/oauth/oauth_controller.ex +++ b/lib/pleroma/web/oauth/oauth_controller.ex @@ -36,7 +36,7 @@ def authorize(%Plug.Conn{} = conn, %{"authorization" => _} = params) do authorize(conn, Map.merge(params, auth_attrs)) end - def authorize(%Plug.Conn{assigns: %{token: %Token{}}} = conn, params) do + def authorize(%Plug.Conn{assigns: %{token: %Token{}}} = conn, %{"force_login" => _} = params) do if ControllerHelper.truthy_param?(params["force_login"]) do do_authorize(conn, params) else @@ -44,6 +44,22 @@ def authorize(%Plug.Conn{assigns: %{token: %Token{}}} = conn, params) do end end + # Note: the token is set in oauth_plug, but the token and client do not always go together. + # For example, MastodonFE's token is set if user requests with another client, + # after user already authorized to MastodonFE. + # So we have to check client and token. + def authorize( + %Plug.Conn{assigns: %{token: %Token{} = token}} = conn, + %{"client_id" => client_id} = params + ) do + with %Token{} = t <- Repo.get_by(Token, token: token.token) |> Repo.preload(:app), + ^client_id <- t.app.client_id do + handle_existing_authorization(conn, params) + else + _ -> do_authorize(conn, params) + end + end + def authorize(%Plug.Conn{} = conn, params), do: do_authorize(conn, params) defp do_authorize(%Plug.Conn{} = conn, params) do diff --git a/test/web/oauth/oauth_controller_test.exs b/test/web/oauth/oauth_controller_test.exs index ad8d79083..beb995cd8 100644 --- a/test/web/oauth/oauth_controller_test.exs +++ b/test/web/oauth/oauth_controller_test.exs @@ -469,6 +469,29 @@ test "renders authentication page if user is already authenticated but `force_lo assert html_response(conn, 200) =~ ~s(type="submit") end + test "renders authentication page if user is already authenticated but user request with another client", + %{ + app: app, + conn: conn + } do + token = insert(:oauth_token, app_id: app.id) + + conn = + conn + |> put_session(:oauth_token, token.token) + |> get( + "/oauth/authorize", + %{ + "response_type" => "code", + "client_id" => "another_client_id", + "redirect_uri" => OAuthController.default_redirect_uri(app), + "scope" => "read" + } + ) + + assert html_response(conn, 200) =~ ~s(type="submit") + end + test "with existing authentication and non-OOB `redirect_uri`, redirects to app with `token` and `state` params", %{ app: app, From d5dc0c4a7e39611ca1aac1691038e5a9ab425dad Mon Sep 17 00:00:00 2001 From: rinpatch Date: Tue, 5 Nov 2019 23:45:07 +0300 Subject: [PATCH 075/154] CI: Remove the docs-build job The artifacts it produces were no longer used since we switched to mkdocs. --- .gitlab-ci.yml | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 04af8c186..0f8a0659b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -29,22 +29,6 @@ build: - mix deps.get - mix compile --force -docs-build: - stage: build - only: - - master@pleroma/pleroma - - develop@pleroma/pleroma - variables: - MIX_ENV: dev - PLEROMA_BUILD_ENV: prod - script: - - mix deps.get - - mix compile - - mix docs - artifacts: - paths: - - priv/static/doc - benchmark: stage: benchmark variables: From 54746c6c26dcbb377e651e196d41f2d7dd87f233 Mon Sep 17 00:00:00 2001 From: rinpatch Date: Wed, 6 Nov 2019 14:00:03 +0300 Subject: [PATCH 076/154] Object Fetcher: set cache after reinjecting Probably fixes the issue hj had, where polls would have different counters between endpoints. --- lib/pleroma/object/fetcher.ex | 3 ++- test/object_test.exs | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/pleroma/object/fetcher.ex b/lib/pleroma/object/fetcher.ex index 441ae8b65..3bcbd3aea 100644 --- a/lib/pleroma/object/fetcher.ex +++ b/lib/pleroma/object/fetcher.ex @@ -38,7 +38,8 @@ defp reinject_object(struct, data) do data <- maybe_reinject_internal_fields(data, struct), changeset <- Object.change(struct, %{data: data}), changeset <- touch_changeset(changeset), - {:ok, object} <- Repo.insert_or_update(changeset) do + {:ok, object} <- Repo.insert_or_update(changeset), + {:ok, object} <- Object.set_cache(object) do {:ok, object} else e -> diff --git a/test/object_test.exs b/test/object_test.exs index dd228c32f..9247a6d84 100644 --- a/test/object_test.exs +++ b/test/object_test.exs @@ -124,6 +124,8 @@ test "refetches if the time since the last refetch is greater than the interval" %Object{} = object = Object.normalize("https://patch.cx/objects/9a172665-2bc5-452d-8428-2361d4c33b1d") + Object.set_cache(object) + assert Enum.at(object.data["oneOf"], 0)["replies"]["totalItems"] == 4 assert Enum.at(object.data["oneOf"], 1)["replies"]["totalItems"] == 0 @@ -133,6 +135,8 @@ test "refetches if the time since the last refetch is greater than the interval" }) updated_object = Object.get_by_id_and_maybe_refetch(object.id, interval: -1) + object_in_cache = Object.get_cached_by_ap_id(object.data["id"]) + assert updated_object == object_in_cache assert Enum.at(updated_object.data["oneOf"], 0)["replies"]["totalItems"] == 8 assert Enum.at(updated_object.data["oneOf"], 1)["replies"]["totalItems"] == 3 end @@ -141,6 +145,8 @@ test "returns the old object if refetch fails", %{mock_modified: mock_modified} %Object{} = object = Object.normalize("https://patch.cx/objects/9a172665-2bc5-452d-8428-2361d4c33b1d") + Object.set_cache(object) + assert Enum.at(object.data["oneOf"], 0)["replies"]["totalItems"] == 4 assert Enum.at(object.data["oneOf"], 1)["replies"]["totalItems"] == 0 @@ -148,6 +154,8 @@ test "returns the old object if refetch fails", %{mock_modified: mock_modified} mock_modified.(%Tesla.Env{status: 404, body: ""}) updated_object = Object.get_by_id_and_maybe_refetch(object.id, interval: -1) + object_in_cache = Object.get_cached_by_ap_id(object.data["id"]) + assert updated_object == object_in_cache assert Enum.at(updated_object.data["oneOf"], 0)["replies"]["totalItems"] == 4 assert Enum.at(updated_object.data["oneOf"], 1)["replies"]["totalItems"] == 0 end) =~ @@ -160,6 +168,8 @@ test "does not refetch if the time since the last refetch is greater than the in %Object{} = object = Object.normalize("https://patch.cx/objects/9a172665-2bc5-452d-8428-2361d4c33b1d") + Object.set_cache(object) + assert Enum.at(object.data["oneOf"], 0)["replies"]["totalItems"] == 4 assert Enum.at(object.data["oneOf"], 1)["replies"]["totalItems"] == 0 @@ -169,6 +179,8 @@ test "does not refetch if the time since the last refetch is greater than the in }) updated_object = Object.get_by_id_and_maybe_refetch(object.id, interval: 100) + object_in_cache = Object.get_cached_by_ap_id(object.data["id"]) + assert updated_object == object_in_cache assert Enum.at(updated_object.data["oneOf"], 0)["replies"]["totalItems"] == 4 assert Enum.at(updated_object.data["oneOf"], 1)["replies"]["totalItems"] == 0 end @@ -177,6 +189,8 @@ test "preserves internal fields on refetch", %{mock_modified: mock_modified} do %Object{} = object = Object.normalize("https://patch.cx/objects/9a172665-2bc5-452d-8428-2361d4c33b1d") + Object.set_cache(object) + assert Enum.at(object.data["oneOf"], 0)["replies"]["totalItems"] == 4 assert Enum.at(object.data["oneOf"], 1)["replies"]["totalItems"] == 0 @@ -192,6 +206,8 @@ test "preserves internal fields on refetch", %{mock_modified: mock_modified} do }) updated_object = Object.get_by_id_and_maybe_refetch(object.id, interval: -1) + object_in_cache = Object.get_cached_by_ap_id(object.data["id"]) + assert updated_object == object_in_cache assert Enum.at(updated_object.data["oneOf"], 0)["replies"]["totalItems"] == 8 assert Enum.at(updated_object.data["oneOf"], 1)["replies"]["totalItems"] == 3 From 84175fe30e3661cafe6d5a0a5c7243a60b7d0ff0 Mon Sep 17 00:00:00 2001 From: rinpatch Date: Wed, 6 Nov 2019 16:41:19 +0300 Subject: [PATCH 077/154] Set better Cache-Control header for static content Closes #1382 --- lib/pleroma/web/endpoint.ex | 2 +- test/plugs/cache_control_test.exs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pleroma/web/endpoint.ex b/lib/pleroma/web/endpoint.ex index 2212e93f4..49735b5c2 100644 --- a/lib/pleroma/web/endpoint.ex +++ b/lib/pleroma/web/endpoint.ex @@ -12,7 +12,7 @@ defmodule Pleroma.Web.Endpoint do plug(Pleroma.Plugs.HTTPSecurityPlug) plug(Pleroma.Plugs.UploadedMedia) - @static_cache_control "public, no-cache" + @static_cache_control "public max-age=86400 must-revalidate" # InstanceStatic needs to be before Plug.Static to be able to override shipped-static files # If you're adding new paths to `only:` you'll need to configure them in InstanceStatic as well diff --git a/test/plugs/cache_control_test.exs b/test/plugs/cache_control_test.exs index 69ce6cc7d..be78b3e1e 100644 --- a/test/plugs/cache_control_test.exs +++ b/test/plugs/cache_control_test.exs @@ -9,7 +9,7 @@ defmodule Pleroma.Web.CacheControlTest do test "Verify Cache-Control header on static assets", %{conn: conn} do conn = get(conn, "/index.html") - assert Conn.get_resp_header(conn, "cache-control") == ["public, no-cache"] + assert Conn.get_resp_header(conn, "cache-control") == ["public max-age=86400 must-revalidate"] end test "Verify Cache-Control header on the API", %{conn: conn} do From 66c502879ba35b21e104af3a3897a96a22281335 Mon Sep 17 00:00:00 2001 From: Ivan Tashkinov Date: Wed, 6 Nov 2019 17:19:32 +0300 Subject: [PATCH 078/154] Removed duplicate Changed entry in Unreleased section of CHANGELOG.md. --- CHANGELOG.md | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 85079512a..9fd46b650 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,9 +16,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Add `rel="ugc"` to all links in statuses, to prevent SEO spam - Extract RSS functionality from OStatus - MRF (Simple Policy): Also use `:accept`/`:reject` on the actors rather than only their activities +- OStatus: Extract RSS functionality +- Deprecated `User.Info` embedded schema (fields moved to `User`) +- Store status data inside Flag activity
API Changes +- **Breaking** Admin API: `PATCH /api/pleroma/admin/users/:nickname/force_password_reset` is now `PATCH /api/pleroma/admin/users/force_password_reset` (accepts `nicknames` array in the request body) - **Breaking:** Admin API: Return link alongside with token on password reset - **Breaking:** `/api/pleroma/admin/users/invite_token` now uses `POST`, changed accepted params and returns full invite in json instead of only token string. - Admin API: Return `total` when querying for reports @@ -53,22 +57,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Admin API: Add `GET /api/pleroma/admin/relay` endpoint - lists all followed relays - Pleroma API: `POST /api/v1/pleroma/conversations/read` to mark all conversations as read - Mastodon API: Add `/api/v1/markers` for managing timeline read markers - -### Changed -- **Breaking:** Elixir >=1.8 is now required (was >= 1.7) -- **Breaking:** Admin API: Return link alongside with token on password reset -- Replaced [pleroma_job_queue](https://git.pleroma.social/pleroma/pleroma_job_queue) and `Pleroma.Web.Federator.RetryQueue` with [Oban](https://github.com/sorentwo/oban) (see [`docs/config.md`](docs/config.md) on migrating customized worker / retry settings) -- Introduced [quantum](https://github.com/quantum-elixir/quantum-core) job scheduler -- Admin API: Return `total` when querying for reports -- Mastodon API: Return `pleroma.direct_conversation_id` when creating a direct message (`POST /api/v1/statuses`) -- Admin API: Return link alongside with token on password reset -- MRF (Simple Policy): Also use `:accept`/`:reject` on the actors rather than only their activities -- OStatus: Extract RSS functionality -- Mastodon API: Add `pleroma.direct_conversation_id` to the status endpoint (`GET /api/v1/statuses/:id`) -- Mastodon API: Mark the direct conversation as read for the author when they send a new direct message -- Deprecated `User.Info` embedded schema (fields moved to `User`) -- **Breaking** Admin API: `PATCH /api/pleroma/admin/users/:nickname/force_password_reset` is now `PATCH /api/pleroma/admin/users/force_password_reset` (accepts `nicknames` array in the request body) -- Store status data inside Flag activity
### Fixed From 365657320c27d3fc379cf742d1339dd7871255dd Mon Sep 17 00:00:00 2001 From: rinpatch Date: Wed, 6 Nov 2019 17:22:23 +0300 Subject: [PATCH 079/154] Fix TrailingFormatPlug not being active for /api/oauth_tokens --- lib/pleroma/plugs/trailing_format_plug.ex | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/pleroma/plugs/trailing_format_plug.ex b/lib/pleroma/plugs/trailing_format_plug.ex index ce366b218..a4b8a406d 100644 --- a/lib/pleroma/plugs/trailing_format_plug.ex +++ b/lib/pleroma/plugs/trailing_format_plug.ex @@ -24,7 +24,8 @@ defmodule Pleroma.Plugs.TrailingFormatPlug do "/api/help", "/api/externalprofile", "/notice", - "/api/pleroma/emoji" + "/api/pleroma/emoji", + "/api/oauth_tokens" ] def init(opts) do From 32afa07995997d6ac8e0bbc7a16bfea8f3eeeed4 Mon Sep 17 00:00:00 2001 From: rinpatch Date: Thu, 7 Nov 2019 01:40:55 +0300 Subject: [PATCH 080/154] Fetcher: fix local check returning unwrapped object This resulted in error messages about failed refetches being logged. --- lib/pleroma/object/fetcher.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pleroma/object/fetcher.ex b/lib/pleroma/object/fetcher.ex index 3bcbd3aea..9a9a46550 100644 --- a/lib/pleroma/object/fetcher.ex +++ b/lib/pleroma/object/fetcher.ex @@ -54,7 +54,7 @@ def refetch_object(%Object{data: %{"id" => id}} = object) do {:ok, object} <- reinject_object(object, data) do {:ok, object} else - {:local, true} -> object + {:local, true} -> {:ok, object} e -> {:error, e} end end From 7888803ffed428438ed107d35a856647a46b347d Mon Sep 17 00:00:00 2001 From: eugenijm Date: Thu, 7 Nov 2019 03:00:21 +0300 Subject: [PATCH 081/154] Mastodon API: Add the `recipients` parameter to `GET /api/v1/conversations` --- CHANGELOG.md | 1 + docs/API/differences_in_mastoapi_responses.md | 6 +++ lib/pleroma/conversation/participation.ex | 28 ++++++++++ .../conversation_controller_test.exs | 53 +++++++++++++++++++ 4 files changed, 88 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9fd46b650..b33d61819 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -57,6 +57,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Admin API: Add `GET /api/pleroma/admin/relay` endpoint - lists all followed relays - Pleroma API: `POST /api/v1/pleroma/conversations/read` to mark all conversations as read - Mastodon API: Add `/api/v1/markers` for managing timeline read markers +- Mastodon API: Add the `recipients` parameter to `GET /api/v1/conversations` ### Fixed diff --git a/docs/API/differences_in_mastoapi_responses.md b/docs/API/differences_in_mastoapi_responses.md index aca0f5e0e..7fbe17130 100644 --- a/docs/API/differences_in_mastoapi_responses.md +++ b/docs/API/differences_in_mastoapi_responses.md @@ -72,6 +72,12 @@ Has an additional field under the `pleroma` object: - `recipients`: The list of the recipients of this Conversation. These will be addressed when replying to this conversation. +## GET `/api/v1/conversations` + +Accepts additional parameters: + +- `recipients`: Only return conversations with the given recipients (a list of user ids). Usage example: `GET /api/v1/conversations?recipients[]=1&recipients[]=2` + ## Account Search Behavior has changed: diff --git a/lib/pleroma/conversation/participation.ex b/lib/pleroma/conversation/participation.ex index 176b82a20..aafe57280 100644 --- a/lib/pleroma/conversation/participation.ex +++ b/lib/pleroma/conversation/participation.ex @@ -122,9 +122,37 @@ def for_user(user, params \\ %{}) do order_by: [desc: p.updated_at], preload: [conversation: [:users]] ) + |> restrict_recipients(user, params) |> Pleroma.Pagination.fetch_paginated(params) end + def restrict_recipients(query, user, %{"recipients" => user_ids}) do + user_ids = + [user.id | user_ids] + |> Enum.uniq() + |> Enum.reduce([], fn user_id, acc -> + case FlakeId.Ecto.CompatType.dump(user_id) do + {:ok, user_id} -> [user_id | acc] + _ -> acc + end + end) + + conversation_subquery = + __MODULE__ + |> group_by([p], p.conversation_id) + |> having( + [p], + count(p.user_id) == ^length(user_ids) and + fragment("array_agg(?) @> ?", p.user_id, ^user_ids) + ) + |> select([p], %{id: p.conversation_id}) + + query + |> join(:inner, [p], c in subquery(conversation_subquery), on: p.conversation_id == c.id) + end + + def restrict_recipients(query, _, _), do: query + def for_user_and_conversation(user, conversation) do from(p in __MODULE__, where: p.user_id == ^user.id, diff --git a/test/web/mastodon_api/controllers/conversation_controller_test.exs b/test/web/mastodon_api/controllers/conversation_controller_test.exs index 542af4944..2a1223b18 100644 --- a/test/web/mastodon_api/controllers/conversation_controller_test.exs +++ b/test/web/mastodon_api/controllers/conversation_controller_test.exs @@ -59,6 +59,59 @@ test "returns a list of conversations", %{conn: conn} do assert User.get_cached_by_id(user_one.id).unread_conversation_count == 0 end + test "filters conversations by recipients", %{conn: conn} do + user_one = insert(:user) + user_two = insert(:user) + user_three = insert(:user) + + {:ok, direct1} = + CommonAPI.post(user_one, %{ + "status" => "Hi @#{user_two.nickname}!", + "visibility" => "direct" + }) + + {:ok, _direct2} = + CommonAPI.post(user_one, %{ + "status" => "Hi @#{user_three.nickname}!", + "visibility" => "direct" + }) + + {:ok, direct3} = + CommonAPI.post(user_one, %{ + "status" => "Hi @#{user_two.nickname}, @#{user_three.nickname}!", + "visibility" => "direct" + }) + + {:ok, _direct4} = + CommonAPI.post(user_two, %{ + "status" => "Hi @#{user_three.nickname}!", + "visibility" => "direct" + }) + + {:ok, direct5} = + CommonAPI.post(user_two, %{ + "status" => "Hi @#{user_one.nickname}!", + "visibility" => "direct" + }) + + [conversation1, conversation2] = + conn + |> assign(:user, user_one) + |> get("/api/v1/conversations", %{"recipients" => [user_two.id]}) + |> json_response(200) + + assert conversation1["last_status"]["id"] == direct5.id + assert conversation2["last_status"]["id"] == direct1.id + + [conversation1] = + conn + |> assign(:user, user_one) + |> get("/api/v1/conversations", %{"recipients" => [user_two.id, user_three.id]}) + |> json_response(200) + + assert conversation1["last_status"]["id"] == direct3.id + end + test "updates the last_status on reply", %{conn: conn} do user_one = insert(:user) user_two = insert(:user) From 2f4e9a068f334167ebf79d30b4366d1e2504b7ef Mon Sep 17 00:00:00 2001 From: rinpatch Date: Fri, 8 Nov 2019 00:14:53 +0300 Subject: [PATCH 082/154] Bump fast_sanitize to 0.1.1 The parser C-Node has been completely rewritten to not use the deprecated `erl_interface` api. Closes #1378 since Nodex was ripped out and the replacement randomizes master node name. --- config/config.exs | 2 +- mix.exs | 6 ++---- mix.lock | 3 ++- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/config/config.exs b/config/config.exs index 81d50cdee..787809b27 100644 --- a/config/config.exs +++ b/config/config.exs @@ -603,7 +603,7 @@ activity_pub: nil, activity_pub_question: 30_000 -config :swarm, node_blacklist: [~r/myhtmlex_.*$/] +config :swarm, node_blacklist: [~r/myhtml_.*$/] # Import environment specific config. This must remain at the bottom # of this file so it overrides the configuration defined above. import_config "#{Mix.env()}.exs" diff --git a/mix.exs b/mix.exs index 0a3a03a61..dd7c7e979 100644 --- a/mix.exs +++ b/mix.exs @@ -63,7 +63,7 @@ def copy_nginx_config(%{path: target_path} = release) do def application do [ mod: {Pleroma.Application, []}, - extra_applications: [:logger, :runtime_tools, :comeonin, :quack, :myhtmlex, :swarm], + extra_applications: [:logger, :runtime_tools, :comeonin, :quack, :fast_sanitize, :swarm], included_applications: [:ex_syslogger] ] end @@ -108,9 +108,7 @@ defp deps do {:comeonin, "~> 4.1.1"}, {:pbkdf2_elixir, "~> 0.12.3"}, {:trailing_format_plug, "~> 0.0.7"}, - {:fast_sanitize, - git: "https://git.pleroma.social/pleroma/fast_sanitize.git", - ref: "1af67547a02a104e26c99d03012383e8643bc4c2"}, + {:fast_sanitize, "~> 0.1"}, {:html_entities, "~> 0.5", override: true}, {:phoenix_html, "~> 2.10"}, {:calendar, "~> 0.17.4"}, diff --git a/mix.lock b/mix.lock index 082665c3c..c707667b2 100644 --- a/mix.lock +++ b/mix.lock @@ -36,7 +36,8 @@ "ex_rated": {:hex, :ex_rated, "1.3.3", "30ecbdabe91f7eaa9d37fa4e81c85ba420f371babeb9d1910adbcd79ec798d27", [:mix], [{:ex2ms, "~> 1.5", [hex: :ex2ms, repo: "hexpm", optional: false]}], "hexpm"}, "ex_syslogger": {:git, "https://github.com/slashmili/ex_syslogger.git", "f3963399047af17e038897c69e20d552e6899e1d", [tag: "1.4.0"]}, "excoveralls": {:hex, :excoveralls, "0.11.2", "0c6f2c8db7683b0caa9d490fb8125709c54580b4255ffa7ad35f3264b075a643", [:mix], [{:hackney, "~> 1.0", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm"}, - "fast_sanitize": {:git, "https://git.pleroma.social/pleroma/fast_sanitize.git", "1af67547a02a104e26c99d03012383e8643bc4c2", [ref: "1af67547a02a104e26c99d03012383e8643bc4c2"]}, + "fast_html": {:hex, :fast_html, "0.99.0", "ea740358b15c7da6085b421b775f22d4f2c6928a28a15ebb5ad4e8a2ce00350b", [:make, :mix], [], "hexpm"}, + "fast_sanitize": {:hex, :fast_sanitize, "0.1.1", "a403c3c09369e23423d3e6beb14068ad07be82741d10b293c71abac445dcc636", [:mix], [{:fast_html, "~> 0.99", [hex: :fast_html, repo: "hexpm", optional: false]}, {:plug, "~> 1.8", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"}, "flake_id": {:hex, :flake_id, "0.1.0", "7716b086d2e405d09b647121a166498a0d93d1a623bead243e1f74216079ccb3", [:mix], [{:base62, "~> 1.2", [hex: :base62, repo: "hexpm", optional: false]}, {:ecto, ">= 2.0.0", [hex: :ecto, repo: "hexpm", optional: true]}], "hexpm"}, "floki": {:hex, :floki, "0.23.0", "956ab6dba828c96e732454809fb0bd8d43ce0979b75f34de6322e73d4c917829", [:mix], [{:html_entities, "~> 0.4.0", [hex: :html_entities, repo: "hexpm", optional: false]}], "hexpm"}, "gen_smtp": {:hex, :gen_smtp, "0.15.0", "9f51960c17769b26833b50df0b96123605a8024738b62db747fece14eb2fbfcc", [:rebar3], [], "hexpm"}, From 44f942e17d467c9ac938174fb71e71552595777c Mon Sep 17 00:00:00 2001 From: rinpatch Date: Fri, 8 Nov 2019 19:40:13 +0300 Subject: [PATCH 083/154] Bump fast_sanitize to 0.1.2 Fixes build issues on macOS --- mix.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mix.lock b/mix.lock index c707667b2..3defb187a 100644 --- a/mix.lock +++ b/mix.lock @@ -36,8 +36,8 @@ "ex_rated": {:hex, :ex_rated, "1.3.3", "30ecbdabe91f7eaa9d37fa4e81c85ba420f371babeb9d1910adbcd79ec798d27", [:mix], [{:ex2ms, "~> 1.5", [hex: :ex2ms, repo: "hexpm", optional: false]}], "hexpm"}, "ex_syslogger": {:git, "https://github.com/slashmili/ex_syslogger.git", "f3963399047af17e038897c69e20d552e6899e1d", [tag: "1.4.0"]}, "excoveralls": {:hex, :excoveralls, "0.11.2", "0c6f2c8db7683b0caa9d490fb8125709c54580b4255ffa7ad35f3264b075a643", [:mix], [{:hackney, "~> 1.0", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm"}, - "fast_html": {:hex, :fast_html, "0.99.0", "ea740358b15c7da6085b421b775f22d4f2c6928a28a15ebb5ad4e8a2ce00350b", [:make, :mix], [], "hexpm"}, - "fast_sanitize": {:hex, :fast_sanitize, "0.1.1", "a403c3c09369e23423d3e6beb14068ad07be82741d10b293c71abac445dcc636", [:mix], [{:fast_html, "~> 0.99", [hex: :fast_html, repo: "hexpm", optional: false]}, {:plug, "~> 1.8", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"}, + "fast_html": {:hex, :fast_html, "0.99.1", "364e028e9926f70d5c1def452464828a25c63d1162db48592fdfe7c487d197d7", [:make, :mix], [], "hexpm"}, + "fast_sanitize": {:hex, :fast_sanitize, "0.1.2", "831284da9559a4f0c29b9a774227c9b904aac796d03b1267fa46802ab110fee3", [:mix], [{:fast_html, "~> 0.99", [hex: :fast_html, repo: "hexpm", optional: false]}, {:plug, "~> 1.8", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"}, "flake_id": {:hex, :flake_id, "0.1.0", "7716b086d2e405d09b647121a166498a0d93d1a623bead243e1f74216079ccb3", [:mix], [{:base62, "~> 1.2", [hex: :base62, repo: "hexpm", optional: false]}, {:ecto, ">= 2.0.0", [hex: :ecto, repo: "hexpm", optional: true]}], "hexpm"}, "floki": {:hex, :floki, "0.23.0", "956ab6dba828c96e732454809fb0bd8d43ce0979b75f34de6322e73d4c917829", [:mix], [{:html_entities, "~> 0.4.0", [hex: :html_entities, repo: "hexpm", optional: false]}], "hexpm"}, "gen_smtp": {:hex, :gen_smtp, "0.15.0", "9f51960c17769b26833b50df0b96123605a8024738b62db747fece14eb2fbfcc", [:rebar3], [], "hexpm"}, From 532fd38b123b94e6a60387bd8c8409e50913e81a Mon Sep 17 00:00:00 2001 From: Ariadne Conill Date: Fri, 8 Nov 2019 12:48:28 -0600 Subject: [PATCH 084/154] nodeinfo: add multifetch feature (ref pleroma-fe!977). --- lib/pleroma/web/nodeinfo/nodeinfo_controller.ex | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pleroma/web/nodeinfo/nodeinfo_controller.ex b/lib/pleroma/web/nodeinfo/nodeinfo_controller.ex index 192984242..d7ae503f6 100644 --- a/lib/pleroma/web/nodeinfo/nodeinfo_controller.ex +++ b/lib/pleroma/web/nodeinfo/nodeinfo_controller.ex @@ -58,6 +58,7 @@ def raw_nodeinfo do "polls", "pleroma_explicit_addressing", "shareable_emoji_packs", + "multifetch", if Config.get([:media_proxy, :enabled]) do "media_proxy" end, From 1b58b5c8db28a082a6356416cf965af4c5db9b00 Mon Sep 17 00:00:00 2001 From: rinpatch Date: Fri, 8 Nov 2019 22:22:39 +0300 Subject: [PATCH 085/154] Bump fast_sanitize Fixes build fails on freebsd --- mix.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mix.lock b/mix.lock index 3defb187a..5b471fe3d 100644 --- a/mix.lock +++ b/mix.lock @@ -36,8 +36,8 @@ "ex_rated": {:hex, :ex_rated, "1.3.3", "30ecbdabe91f7eaa9d37fa4e81c85ba420f371babeb9d1910adbcd79ec798d27", [:mix], [{:ex2ms, "~> 1.5", [hex: :ex2ms, repo: "hexpm", optional: false]}], "hexpm"}, "ex_syslogger": {:git, "https://github.com/slashmili/ex_syslogger.git", "f3963399047af17e038897c69e20d552e6899e1d", [tag: "1.4.0"]}, "excoveralls": {:hex, :excoveralls, "0.11.2", "0c6f2c8db7683b0caa9d490fb8125709c54580b4255ffa7ad35f3264b075a643", [:mix], [{:hackney, "~> 1.0", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm"}, - "fast_html": {:hex, :fast_html, "0.99.1", "364e028e9926f70d5c1def452464828a25c63d1162db48592fdfe7c487d197d7", [:make, :mix], [], "hexpm"}, - "fast_sanitize": {:hex, :fast_sanitize, "0.1.2", "831284da9559a4f0c29b9a774227c9b904aac796d03b1267fa46802ab110fee3", [:mix], [{:fast_html, "~> 0.99", [hex: :fast_html, repo: "hexpm", optional: false]}, {:plug, "~> 1.8", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"}, + "fast_html": {:hex, :fast_html, "0.99.3", "e7ce6245fed0635f4719a31cc409091ed17b2091165a4a1cffbf2ceac77abbf4", [:make, :mix], [], "hexpm"}, + "fast_sanitize": {:hex, :fast_sanitize, "0.1.3", "e89a743b1679c344abdfcf79778d1499fbc599eca2d8a8cdfaf9ff520986fb72", [:mix], [{:fast_html, "~> 0.99", [hex: :fast_html, repo: "hexpm", optional: false]}, {:plug, "~> 1.8", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"}, "flake_id": {:hex, :flake_id, "0.1.0", "7716b086d2e405d09b647121a166498a0d93d1a623bead243e1f74216079ccb3", [:mix], [{:base62, "~> 1.2", [hex: :base62, repo: "hexpm", optional: false]}, {:ecto, ">= 2.0.0", [hex: :ecto, repo: "hexpm", optional: true]}], "hexpm"}, "floki": {:hex, :floki, "0.23.0", "956ab6dba828c96e732454809fb0bd8d43ce0979b75f34de6322e73d4c917829", [:mix], [{:html_entities, "~> 0.4.0", [hex: :html_entities, repo: "hexpm", optional: false]}], "hexpm"}, "gen_smtp": {:hex, :gen_smtp, "0.15.0", "9f51960c17769b26833b50df0b96123605a8024738b62db747fece14eb2fbfcc", [:rebar3], [], "hexpm"}, From 5b60d82592e3fd19646add354de4cde903abf38c Mon Sep 17 00:00:00 2001 From: Ariadne Conill Date: Fri, 8 Nov 2019 14:51:28 -0600 Subject: [PATCH 086/154] object containment: handle all cases where ID is invalid (missing, nil, non-string) --- lib/pleroma/object/containment.ex | 6 +++--- test/object/containment_test.exs | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/lib/pleroma/object/containment.ex b/lib/pleroma/object/containment.ex index 68535c09e..a1f9c1250 100644 --- a/lib/pleroma/object/containment.ex +++ b/lib/pleroma/object/containment.ex @@ -64,15 +64,15 @@ def contain_origin(id, %{"actor" => _actor} = params) do def contain_origin(id, %{"attributedTo" => actor} = params), do: contain_origin(id, Map.put(params, "actor", actor)) - def contain_origin_from_id(_id, %{"id" => nil}), do: :error - - def contain_origin_from_id(id, %{"id" => other_id} = _params) do + def contain_origin_from_id(id, %{"id" => other_id} = _params) when is_binary(other_id) do id_uri = URI.parse(id) other_uri = URI.parse(other_id) compare_uris(id_uri, other_uri) end + def contain_origin_from_id(_id, _data), do: :error + def contain_child(%{"object" => %{"id" => id, "attributedTo" => _} = object}), do: contain_origin(id, object) diff --git a/test/object/containment_test.exs b/test/object/containment_test.exs index 0dc2728b9..71fe5204c 100644 --- a/test/object/containment_test.exs +++ b/test/object/containment_test.exs @@ -67,6 +67,20 @@ test "users cannot be collided through fake direction spoofing attempts" do end) =~ "[error] Could not decode user at fetch https://n1u.moe/users/rye" end + + test "contain_origin_from_id() gracefully handles cases where no ID is present" do + data = %{ + "type" => "Create", + "object" => %{ + "id" => "http://example.net/~alyssa/activities/1234", + "attributedTo" => "http://example.org/~alyssa" + }, + "actor" => "http://example.com/~bob" + } + + :error = + Containment.contain_origin_from_id("http://example.net/~alyssa/activities/1234", data) + end end describe "containment of children" do From 3cc24375988fa7893cead1358899f5096a6ded86 Mon Sep 17 00:00:00 2001 From: rinpatch Date: Sat, 9 Nov 2019 01:47:32 +0300 Subject: [PATCH 087/154] Bump pleroma-fe bundle to 044c9ad0562af059dd961d50961a3880fca9c642 --- priv/static/index.html | 2 +- ...ff399.css => app.fd71461124f3eb029b1b.css} | 2 +- ...s.map => app.fd71461124f3eb029b1b.css.map} | 2 +- .../static/js/2.48f39bc510b7c0a7fca6.js | 2 - .../static/js/2.73375b727cef616c59b4.js | 2 + ...6.js.map => 2.73375b727cef616c59b4.js.map} | 2 +- .../static/js/app.105d64a8fcdd6724ccde.js | 2 + .../static/js/app.105d64a8fcdd6724ccde.js.map | 1 + .../vendors~app.24e6ba2d196f6210feda.js.map | 1 - ...js => vendors~app.5c3fab032deb5f2793cb.js} | 18 +++--- .../vendors~app.5c3fab032deb5f2793cb.js.map | 1 + priv/static/static/styles.json | 4 +- priv/static/static/themes/mammal.json | 57 +++++++++++++++++++ priv/static/sw-pleroma.js | 2 +- 14 files changed, 79 insertions(+), 19 deletions(-) rename priv/static/static/css/{app.4e8e80a2f95232cff399.css => app.fd71461124f3eb029b1b.css} (97%) rename priv/static/static/css/{app.4e8e80a2f95232cff399.css.map => app.fd71461124f3eb029b1b.css.map} (95%) delete mode 100644 priv/static/static/js/2.48f39bc510b7c0a7fca6.js create mode 100644 priv/static/static/js/2.73375b727cef616c59b4.js rename priv/static/static/js/{2.48f39bc510b7c0a7fca6.js.map => 2.73375b727cef616c59b4.js.map} (92%) create mode 100644 priv/static/static/js/app.105d64a8fcdd6724ccde.js create mode 100644 priv/static/static/js/app.105d64a8fcdd6724ccde.js.map delete mode 100644 priv/static/static/js/vendors~app.24e6ba2d196f6210feda.js.map rename priv/static/static/js/{vendors~app.24e6ba2d196f6210feda.js => vendors~app.5c3fab032deb5f2793cb.js} (59%) create mode 100644 priv/static/static/js/vendors~app.5c3fab032deb5f2793cb.js.map create mode 100644 priv/static/static/themes/mammal.json diff --git a/priv/static/index.html b/priv/static/index.html index fc5eee901..f1a26cc95 100644 --- a/priv/static/index.html +++ b/priv/static/index.html @@ -1 +1 @@ -Pleroma
\ No newline at end of file +Pleroma
\ No newline at end of file diff --git a/priv/static/static/css/app.4e8e80a2f95232cff399.css b/priv/static/static/css/app.fd71461124f3eb029b1b.css similarity index 97% rename from priv/static/static/css/app.4e8e80a2f95232cff399.css rename to priv/static/static/css/app.fd71461124f3eb029b1b.css index ca3d4e41f..6ab9849ec 100644 --- a/priv/static/static/css/app.4e8e80a2f95232cff399.css +++ b/priv/static/static/css/app.fd71461124f3eb029b1b.css @@ -99,4 +99,4 @@ .with-subscription-loading .error { font-size: 14px; } -/*# sourceMappingURL=app.4e8e80a2f95232cff399.css.map*/ \ No newline at end of file +/*# sourceMappingURL=app.fd71461124f3eb029b1b.css.map*/ \ No newline at end of file diff --git a/priv/static/static/css/app.4e8e80a2f95232cff399.css.map b/priv/static/static/css/app.fd71461124f3eb029b1b.css.map similarity index 95% rename from priv/static/static/css/app.4e8e80a2f95232cff399.css.map rename to priv/static/static/css/app.fd71461124f3eb029b1b.css.map index dc2c92ced..660b09d2c 100644 --- a/priv/static/static/css/app.4e8e80a2f95232cff399.css.map +++ b/priv/static/static/css/app.fd71461124f3eb029b1b.css.map @@ -1 +1 @@ -{"version":3,"sources":["webpack:///./src/hocs/with_load_more/with_load_more.scss","webpack:///./src/components/tab_switcher/tab_switcher.scss","webpack:///./src/hocs/with_subscription/with_subscription.scss"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,C;ACTA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,C;AClFA;AACA;AACA;AACA;AACA;AACA;AACA,C","file":"static/css/app.4e8e80a2f95232cff399.css","sourcesContent":[".with-load-more-footer {\n padding: 10px;\n text-align: center;\n border-top: 1px solid;\n border-top-color: #222;\n border-top-color: var(--border, #222);\n}\n.with-load-more-footer .error {\n font-size: 14px;\n}",".tab-switcher {\n display: -ms-flexbox;\n display: flex;\n -ms-flex-direction: column;\n flex-direction: column;\n}\n.tab-switcher .contents {\n -ms-flex: 1 0 auto;\n flex: 1 0 auto;\n min-height: 0px;\n}\n.tab-switcher .contents .hidden {\n display: none;\n}\n.tab-switcher .contents.scrollable-tabs {\n -ms-flex-preferred-size: 0;\n flex-basis: 0;\n overflow-y: auto;\n}\n.tab-switcher .tabs {\n display: -ms-flexbox;\n display: flex;\n position: relative;\n width: 100%;\n overflow-y: hidden;\n overflow-x: auto;\n padding-top: 5px;\n box-sizing: border-box;\n}\n.tab-switcher .tabs::after, .tab-switcher .tabs::before {\n display: block;\n content: \"\";\n -ms-flex: 1 1 auto;\n flex: 1 1 auto;\n border-bottom: 1px solid;\n border-bottom-color: #222;\n border-bottom-color: var(--border, #222);\n}\n.tab-switcher .tabs .tab-wrapper {\n height: 28px;\n position: relative;\n display: -ms-flexbox;\n display: flex;\n -ms-flex: 0 0 auto;\n flex: 0 0 auto;\n}\n.tab-switcher .tabs .tab-wrapper .tab {\n width: 100%;\n min-width: 1px;\n position: relative;\n border-bottom-left-radius: 0;\n border-bottom-right-radius: 0;\n padding: 6px 1em;\n padding-bottom: 99px;\n margin-bottom: -93px;\n white-space: nowrap;\n}\n.tab-switcher .tabs .tab-wrapper .tab:not(.active) {\n z-index: 4;\n}\n.tab-switcher .tabs .tab-wrapper .tab:not(.active):hover {\n z-index: 6;\n}\n.tab-switcher .tabs .tab-wrapper .tab.active {\n background: transparent;\n z-index: 5;\n}\n.tab-switcher .tabs .tab-wrapper .tab img {\n max-height: 26px;\n vertical-align: top;\n margin-top: -5px;\n}\n.tab-switcher .tabs .tab-wrapper:not(.active)::after {\n content: \"\";\n position: absolute;\n left: 0;\n right: 0;\n bottom: 0;\n z-index: 7;\n border-bottom: 1px solid;\n border-bottom-color: #222;\n border-bottom-color: var(--border, #222);\n}",".with-subscription-loading {\n padding: 10px;\n text-align: center;\n}\n.with-subscription-loading .error {\n font-size: 14px;\n}"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///./src/hocs/with_load_more/with_load_more.scss","webpack:///./src/components/tab_switcher/tab_switcher.scss","webpack:///./src/hocs/with_subscription/with_subscription.scss"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,C;ACTA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,C;AClFA;AACA;AACA;AACA;AACA;AACA;AACA,C","file":"static/css/app.fd71461124f3eb029b1b.css","sourcesContent":[".with-load-more-footer {\n padding: 10px;\n text-align: center;\n border-top: 1px solid;\n border-top-color: #222;\n border-top-color: var(--border, #222);\n}\n.with-load-more-footer .error {\n font-size: 14px;\n}",".tab-switcher {\n display: -ms-flexbox;\n display: flex;\n -ms-flex-direction: column;\n flex-direction: column;\n}\n.tab-switcher .contents {\n -ms-flex: 1 0 auto;\n flex: 1 0 auto;\n min-height: 0px;\n}\n.tab-switcher .contents .hidden {\n display: none;\n}\n.tab-switcher .contents.scrollable-tabs {\n -ms-flex-preferred-size: 0;\n flex-basis: 0;\n overflow-y: auto;\n}\n.tab-switcher .tabs {\n display: -ms-flexbox;\n display: flex;\n position: relative;\n width: 100%;\n overflow-y: hidden;\n overflow-x: auto;\n padding-top: 5px;\n box-sizing: border-box;\n}\n.tab-switcher .tabs::after, .tab-switcher .tabs::before {\n display: block;\n content: \"\";\n -ms-flex: 1 1 auto;\n flex: 1 1 auto;\n border-bottom: 1px solid;\n border-bottom-color: #222;\n border-bottom-color: var(--border, #222);\n}\n.tab-switcher .tabs .tab-wrapper {\n height: 28px;\n position: relative;\n display: -ms-flexbox;\n display: flex;\n -ms-flex: 0 0 auto;\n flex: 0 0 auto;\n}\n.tab-switcher .tabs .tab-wrapper .tab {\n width: 100%;\n min-width: 1px;\n position: relative;\n border-bottom-left-radius: 0;\n border-bottom-right-radius: 0;\n padding: 6px 1em;\n padding-bottom: 99px;\n margin-bottom: -93px;\n white-space: nowrap;\n}\n.tab-switcher .tabs .tab-wrapper .tab:not(.active) {\n z-index: 4;\n}\n.tab-switcher .tabs .tab-wrapper .tab:not(.active):hover {\n z-index: 6;\n}\n.tab-switcher .tabs .tab-wrapper .tab.active {\n background: transparent;\n z-index: 5;\n}\n.tab-switcher .tabs .tab-wrapper .tab img {\n max-height: 26px;\n vertical-align: top;\n margin-top: -5px;\n}\n.tab-switcher .tabs .tab-wrapper:not(.active)::after {\n content: \"\";\n position: absolute;\n left: 0;\n right: 0;\n bottom: 0;\n z-index: 7;\n border-bottom: 1px solid;\n border-bottom-color: #222;\n border-bottom-color: var(--border, #222);\n}",".with-subscription-loading {\n padding: 10px;\n text-align: center;\n}\n.with-subscription-loading .error {\n font-size: 14px;\n}"],"sourceRoot":""} \ No newline at end of file diff --git a/priv/static/static/js/2.48f39bc510b7c0a7fca6.js b/priv/static/static/js/2.48f39bc510b7c0a7fca6.js deleted file mode 100644 index eabbcf690..000000000 --- a/priv/static/static/js/2.48f39bc510b7c0a7fca6.js +++ /dev/null @@ -1,2 +0,0 @@ -(window.webpackJsonp=window.webpackJsonp||[]).push([[2],{987:function(t,e,i){"use strict";i.r(e);var n=i(988),c=i.n(n);for(var r in n)"default"!==r&&function(t){i.d(e,t,function(){return n[t]})}(r);var a=i(991),s=i(0);var o=function(t){i(989)},u=Object(s.a)(c.a,a.a,a.b,!1,o,null,null);e.default=u.exports},988:function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=c(i(332));function c(t){return t&&t.__esModule?t:{default:t}}var r={components:{TabSwitcher:c(i(197)).default},data:function(){return{meta:{stickers:[]},path:""}},computed:{pack:function(){return this.$store.state.instance.stickers||[]}},methods:{clear:function(){this.meta={stickers:[]}},pick:function(t,e){var i=this,c=this.$store;fetch(t).then(function(t){t.blob().then(function(t){var r=new File([t],e,{mimetype:"image/png"}),a=new FormData;a.append("file",r),n.default.uploadMedia({store:c,formData:a}).then(function(t){i.$emit("uploaded",t),i.clear()},function(t){console.warn("Can't attach sticker"),console.warn(t),i.$emit("upload-failed","default")})})})}}};e.default=r},989:function(t,e,i){var n=i(990);"string"==typeof n&&(n=[[t.i,n,""]]),n.locals&&(t.exports=n.locals);(0,i(2).default)("cc6cdea4",n,!0,{})},990:function(t,e,i){(t.exports=i(1)(!1)).push([t.i,".sticker-picker{width:100%;position:relative}.sticker-picker .tab-switcher{position:absolute;top:0;bottom:0;left:0;right:0}.sticker-picker .sticker-picker-content .sticker{display:inline-block;width:20%;height:20%}.sticker-picker .sticker-picker-content .sticker img{width:100%}.sticker-picker .sticker-picker-content .sticker img:hover{filter:drop-shadow(0 0 5px var(--link,#d8a070))}",""])},991:function(t,e,i){"use strict";i.d(e,"a",function(){return n}),i.d(e,"b",function(){return c});var n=function(){var t=this,e=t.$createElement,i=t._self._c||e;return i("div",{staticClass:"sticker-picker"},[i("tab-switcher",{staticClass:"tab-switcher",attrs:{"render-only-focused":!0,"scrollable-tabs":""}},t._l(t.pack,function(e){return i("div",{key:e.path,staticClass:"sticker-picker-content",attrs:{"image-tooltip":e.meta.title,image:e.path+e.meta.tabIcon}},t._l(e.meta.stickers,function(n){return i("div",{key:n,staticClass:"sticker",on:{click:function(i){i.stopPropagation(),i.preventDefault(),t.pick(e.path+n,e.meta.title)}}},[i("img",{attrs:{src:e.path+n}})])}),0)}),0)],1)},c=[]}}]); -//# sourceMappingURL=2.48f39bc510b7c0a7fca6.js.map \ No newline at end of file diff --git a/priv/static/static/js/2.73375b727cef616c59b4.js b/priv/static/static/js/2.73375b727cef616c59b4.js new file mode 100644 index 000000000..ebfd9acbd --- /dev/null +++ b/priv/static/static/js/2.73375b727cef616c59b4.js @@ -0,0 +1,2 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[2],{1012:function(t,e,i){"use strict";i.r(e);var n=i(1013),c=i.n(n);for(var r in n)"default"!==r&&function(t){i.d(e,t,function(){return n[t]})}(r);var a=i(1016),s=i(0);var o=function(t){i(1014)},u=Object(s.a)(c.a,a.a,a.b,!1,o,null,null);e.default=u.exports},1013:function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=c(i(348));function c(t){return t&&t.__esModule?t:{default:t}}var r={components:{TabSwitcher:c(i(205)).default},data:function(){return{meta:{stickers:[]},path:""}},computed:{pack:function(){return this.$store.state.instance.stickers||[]}},methods:{clear:function(){this.meta={stickers:[]}},pick:function(t,e){var i=this,c=this.$store;fetch(t).then(function(t){t.blob().then(function(t){var r=new File([t],e,{mimetype:"image/png"}),a=new FormData;a.append("file",r),n.default.uploadMedia({store:c,formData:a}).then(function(t){i.$emit("uploaded",t),i.clear()},function(t){console.warn("Can't attach sticker"),console.warn(t),i.$emit("upload-failed","default")})})})}}};e.default=r},1014:function(t,e,i){var n=i(1015);"string"==typeof n&&(n=[[t.i,n,""]]),n.locals&&(t.exports=n.locals);(0,i(2).default)("cc6cdea4",n,!0,{})},1015:function(t,e,i){(t.exports=i(1)(!1)).push([t.i,".sticker-picker{width:100%;position:relative}.sticker-picker .tab-switcher{position:absolute;top:0;bottom:0;left:0;right:0}.sticker-picker .sticker-picker-content .sticker{display:inline-block;width:20%;height:20%}.sticker-picker .sticker-picker-content .sticker img{width:100%}.sticker-picker .sticker-picker-content .sticker img:hover{filter:drop-shadow(0 0 5px var(--link,#d8a070))}",""])},1016:function(t,e,i){"use strict";i.d(e,"a",function(){return n}),i.d(e,"b",function(){return c});var n=function(){var t=this,e=t.$createElement,i=t._self._c||e;return i("div",{staticClass:"sticker-picker"},[i("tab-switcher",{staticClass:"tab-switcher",attrs:{"render-only-focused":!0,"scrollable-tabs":""}},t._l(t.pack,function(e){return i("div",{key:e.path,staticClass:"sticker-picker-content",attrs:{"image-tooltip":e.meta.title,image:e.path+e.meta.tabIcon}},t._l(e.meta.stickers,function(n){return i("div",{key:n,staticClass:"sticker",on:{click:function(i){i.stopPropagation(),i.preventDefault(),t.pick(e.path+n,e.meta.title)}}},[i("img",{attrs:{src:e.path+n}})])}),0)}),0)],1)},c=[]}}]); +//# sourceMappingURL=2.73375b727cef616c59b4.js.map \ No newline at end of file diff --git a/priv/static/static/js/2.48f39bc510b7c0a7fca6.js.map b/priv/static/static/js/2.73375b727cef616c59b4.js.map similarity index 92% rename from priv/static/static/js/2.48f39bc510b7c0a7fca6.js.map rename to priv/static/static/js/2.73375b727cef616c59b4.js.map index be87ffa46..d2c864eb3 100644 --- a/priv/static/static/js/2.48f39bc510b7c0a7fca6.js.map +++ b/priv/static/static/js/2.73375b727cef616c59b4.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack:///./src/components/sticker_picker/sticker_picker.vue","webpack:///./src/components/sticker_picker/sticker_picker.js","webpack:///./src/components/sticker_picker/sticker_picker.vue?d6cd","webpack:///./src/components/sticker_picker/sticker_picker.vue?d5ea","webpack:///./src/components/sticker_picker/sticker_picker.vue?8003"],"names":["__webpack_require__","r","__webpack_exports__","_babel_loader_sticker_picker_js__WEBPACK_IMPORTED_MODULE_0__","_babel_loader_sticker_picker_js__WEBPACK_IMPORTED_MODULE_0___default","n","__WEBPACK_IMPORT_KEY__","key","d","_node_modules_vue_loader_lib_template_compiler_index_id_data_v_70972e0c_hasScoped_false_optionsId_0_buble_transforms_node_modules_vue_loader_lib_selector_type_template_index_0_sticker_picker_vue__WEBPACK_IMPORTED_MODULE_1__","_node_modules_vue_loader_lib_runtime_component_normalizer__WEBPACK_IMPORTED_MODULE_2__","__vue_styles__","context","Component","Object","a","StickerPicker","components","TabSwitcher","data","meta","stickers","path","computed","pack","this","$store","state","instance","methods","clear","pick","sticker","name","_this","store","fetch","then","res","blob","file","File","mimetype","formData","FormData","append","statusPosterService","uploadMedia","fileData","$emit","error","console","warn","content","module","i","locals","exports","add","default","push","render","staticRenderFns","_vm","_h","$createElement","_c","_self","staticClass","attrs","render-only-focused","scrollable-tabs","_l","stickerpack","image-tooltip","title","image","tabIcon","on","click","$event","stopPropagation","preventDefault","src"],"mappings":"0FAAAA,EAAAC,EAAAC,GAAA,IAAAC,EAAAH,EAAA,KAAAI,EAAAJ,EAAAK,EAAAF,GAAA,QAAAG,KAAAH,EAAA,YAAAG,GAAA,SAAAC,GAAAP,EAAAQ,EAAAN,EAAAK,EAAA,kBAAAJ,EAAAI,KAAA,CAAAD,GAAA,IAAAG,EAAAT,EAAA,KAAAU,EAAAV,EAAA,GAQA,IAEAW,EAVA,SAAAC,GACEZ,EAAQ,MAeVa,EAAgBC,OAAAJ,EAAA,EAAAI,CACdV,EAAAW,EACAN,EAAA,EACAA,EAAA,GAXF,EAaAE,EATA,KAEA,MAYeT,EAAA,QAAAW,EAAiB,2FCzBhC,QAAAb,EAAA,yDAGA,IAAMgB,EAAgB,CACpBC,WAAY,CACVC,cAJJlB,EAAA,MAIIkB,SAEFC,KAJoB,WAKlB,MAAO,CACLC,KAAM,CACJC,SAAU,IAEZC,KAAM,KAGVC,SAAU,CACRC,KADQ,WAEN,OAAOC,KAAKC,OAAOC,MAAMC,SAASP,UAAY,KAGlDQ,QAAS,CACPC,MADO,WAELL,KAAKL,KAAO,CACVC,SAAU,KAGdU,KANO,SAMDC,EAASC,GAAM,IAAAC,EAAAT,KACbU,EAAQV,KAAKC,OAEnBU,MAAMJ,GACHK,KAAK,SAACC,GACLA,EAAIC,OAAOF,KAAK,SAACE,GACf,IAAIC,EAAO,IAAIC,KAAK,CAACF,GAAON,EAAM,CAAES,SAAU,cAC1CC,EAAW,IAAIC,SACnBD,EAASE,OAAO,OAAQL,GACxBM,UAAoBC,YAAY,CAAEZ,QAAOQ,aACtCN,KAAK,SAACW,GACLd,EAAKe,MAAM,WAAYD,GACvBd,EAAKJ,SACJ,SAACoB,GACFC,QAAQC,KAAK,wBACbD,QAAQC,KAAKF,GACbhB,EAAKe,MAAM,gBAAiB,8BAQ7BjC,uBChDf,IAAAqC,EAAcrD,EAAQ,KACtB,iBAAAqD,MAAA,EAA4CC,EAAAC,EAASF,EAAA,MACrDA,EAAAG,SAAAF,EAAAG,QAAAJ,EAAAG,SAGAE,EADU1D,EAAQ,GAAgE2D,SAClF,WAAAN,GAAA,4BCRAC,EAAAG,QAA2BzD,EAAQ,EAARA,EAA0D,IAKrF4D,KAAA,CAAcN,EAAAC,EAAS,oYAAoY,uCCL3ZvD,EAAAQ,EAAAN,EAAA,sBAAA2D,IAAA7D,EAAAQ,EAAAN,EAAA,sBAAA4D,IAAA,IAAAD,EAAA,WAA0B,IAAAE,EAAAtC,KAAauC,EAAAD,EAAAE,eAA0BC,EAAAH,EAAAI,MAAAD,IAAAF,EAAwB,OAAAE,EAAA,OAAiBE,YAAA,kBAA6B,CAAAF,EAAA,gBAAqBE,YAAA,eAAAC,MAAA,CAAkCC,uBAAA,EAAAC,kBAAA,KAAiDR,EAAAS,GAAAT,EAAA,cAAAU,GAAyC,OAAAP,EAAA,OAAiB3D,IAAAkE,EAAAnD,KAAA8C,YAAA,yBAAAC,MAAA,CAAiEK,gBAAAD,EAAArD,KAAAuD,MAAAC,MAAAH,EAAAnD,KAAAmD,EAAArD,KAAAyD,UAA4Fd,EAAAS,GAAAC,EAAArD,KAAA,kBAAAY,GAAsD,OAAAkC,EAAA,OAAiB3D,IAAAyB,EAAAoC,YAAA,UAAAU,GAAA,CAAsCC,MAAA,SAAAC,GAAyBA,EAAAC,kBAAyBD,EAAAE,iBAAwBnB,EAAAhC,KAAA0C,EAAAnD,KAAAU,EAAAyC,EAAArD,KAAAuD,UAA+D,CAAAT,EAAA,OAAYG,MAAA,CAAOc,IAAAV,EAAAnD,KAAAU,SAAsC,KAAK,QAC1vB8B,EAAA","file":"static/js/2.48f39bc510b7c0a7fca6.js","sourcesContent":["function injectStyle (context) {\n require(\"!!vue-style-loader!css-loader?minimize!../../../node_modules/vue-loader/lib/style-compiler/index?{\\\"optionsId\\\":\\\"0\\\",\\\"vue\\\":true,\\\"scoped\\\":false,\\\"sourceMap\\\":false}!sass-loader!../../../node_modules/vue-loader/lib/selector?type=styles&index=0!./sticker_picker.vue\")\n}\n/* script */\nexport * from \"!!babel-loader!./sticker_picker.js\"\nimport __vue_script__ from \"!!babel-loader!./sticker_picker.js\"/* template */\nimport {render as __vue_render__, staticRenderFns as __vue_static_render_fns__} from \"!!../../../node_modules/vue-loader/lib/template-compiler/index?{\\\"id\\\":\\\"data-v-70972e0c\\\",\\\"hasScoped\\\":false,\\\"optionsId\\\":\\\"0\\\",\\\"buble\\\":{\\\"transforms\\\":{}}}!../../../node_modules/vue-loader/lib/selector?type=template&index=0!./sticker_picker.vue\"\n/* template functional */\nvar __vue_template_functional__ = false\n/* styles */\nvar __vue_styles__ = injectStyle\n/* scopeId */\nvar __vue_scopeId__ = null\n/* moduleIdentifier (server only) */\nvar __vue_module_identifier__ = null\nimport normalizeComponent from \"!../../../node_modules/vue-loader/lib/runtime/component-normalizer\"\nvar Component = normalizeComponent(\n __vue_script__,\n __vue_render__,\n __vue_static_render_fns__,\n __vue_template_functional__,\n __vue_styles__,\n __vue_scopeId__,\n __vue_module_identifier__\n)\n\nexport default Component.exports\n","/* eslint-env browser */\nimport statusPosterService from '../../services/status_poster/status_poster.service.js'\nimport TabSwitcher from '../tab_switcher/tab_switcher.js'\n\nconst StickerPicker = {\n components: {\n TabSwitcher\n },\n data () {\n return {\n meta: {\n stickers: []\n },\n path: ''\n }\n },\n computed: {\n pack () {\n return this.$store.state.instance.stickers || []\n }\n },\n methods: {\n clear () {\n this.meta = {\n stickers: []\n }\n },\n pick (sticker, name) {\n const store = this.$store\n // TODO remove this workaround by finding a way to bypass reuploads\n fetch(sticker)\n .then((res) => {\n res.blob().then((blob) => {\n var file = new File([blob], name, { mimetype: 'image/png' })\n var formData = new FormData()\n formData.append('file', file)\n statusPosterService.uploadMedia({ store, formData })\n .then((fileData) => {\n this.$emit('uploaded', fileData)\n this.clear()\n }, (error) => {\n console.warn(\"Can't attach sticker\")\n console.warn(error)\n this.$emit('upload-failed', 'default')\n })\n })\n })\n }\n }\n}\n\nexport default StickerPicker\n","// style-loader: Adds some css to the DOM by adding a \n","import * as DateUtils from 'src/services/date_utils/date_utils.js'\nimport { uniq } from 'lodash'\n\nexport default {\n name: 'PollForm',\n props: ['visible'],\n data: () => ({\n pollType: 'single',\n options: ['', ''],\n expiryAmount: 10,\n expiryUnit: 'minutes'\n }),\n computed: {\n pollLimits () {\n return this.$store.state.instance.pollLimits\n },\n maxOptions () {\n return this.pollLimits.max_options\n },\n maxLength () {\n return this.pollLimits.max_option_chars\n },\n expiryUnits () {\n const allUnits = ['minutes', 'hours', 'days']\n const expiry = this.convertExpiryFromUnit\n return allUnits.filter(\n unit => this.pollLimits.max_expiration >= expiry(unit, 1)\n )\n },\n minExpirationInCurrentUnit () {\n return Math.ceil(\n this.convertExpiryToUnit(\n this.expiryUnit,\n this.pollLimits.min_expiration\n )\n )\n },\n maxExpirationInCurrentUnit () {\n return Math.floor(\n this.convertExpiryToUnit(\n this.expiryUnit,\n this.pollLimits.max_expiration\n )\n )\n }\n },\n methods: {\n clear () {\n this.pollType = 'single'\n this.options = ['', '']\n this.expiryAmount = 10\n this.expiryUnit = 'minutes'\n },\n nextOption (index) {\n const element = this.$el.querySelector(`#poll-${index + 1}`)\n if (element) {\n element.focus()\n } else {\n // Try adding an option and try focusing on it\n const addedOption = this.addOption()\n if (addedOption) {\n this.$nextTick(function () {\n this.nextOption(index)\n })\n }\n }\n },\n addOption () {\n if (this.options.length < this.maxOptions) {\n this.options.push('')\n return true\n }\n return false\n },\n deleteOption (index, event) {\n if (this.options.length > 2) {\n this.options.splice(index, 1)\n }\n },\n convertExpiryToUnit (unit, amount) {\n // Note: we want seconds and not milliseconds\n switch (unit) {\n case 'minutes': return (1000 * amount) / DateUtils.MINUTE\n case 'hours': return (1000 * amount) / DateUtils.HOUR\n case 'days': return (1000 * amount) / DateUtils.DAY\n }\n },\n convertExpiryFromUnit (unit, amount) {\n // Note: we want seconds and not milliseconds\n switch (unit) {\n case 'minutes': return 0.001 * amount * DateUtils.MINUTE\n case 'hours': return 0.001 * amount * DateUtils.HOUR\n case 'days': return 0.001 * amount * DateUtils.DAY\n }\n },\n expiryAmountChange () {\n this.expiryAmount =\n Math.max(this.minExpirationInCurrentUnit, this.expiryAmount)\n this.expiryAmount =\n Math.min(this.maxExpirationInCurrentUnit, this.expiryAmount)\n this.updatePollToParent()\n },\n updatePollToParent () {\n const expiresIn = this.convertExpiryFromUnit(\n this.expiryUnit,\n this.expiryAmount\n )\n\n const options = uniq(this.options.filter(option => option !== ''))\n if (options.length < 2) {\n this.$emit('update-poll', { error: this.$t('polls.not_enough_options') })\n return\n }\n this.$emit('update-poll', {\n options,\n multiple: this.pollType === 'multiple',\n expiresIn\n })\n }\n }\n}\n","import UserAvatar from '../user_avatar/user_avatar.vue'\nimport RemoteFollow from '../remote_follow/remote_follow.vue'\nimport ProgressButton from '../progress_button/progress_button.vue'\nimport FollowButton from '../follow_button/follow_button.vue'\nimport ModerationTools from '../moderation_tools/moderation_tools.vue'\nimport AccountActions from '../account_actions/account_actions.vue'\nimport { hex2rgb } from '../../services/color_convert/color_convert.js'\nimport generateProfileLink from 'src/services/user_profile_link_generator/user_profile_link_generator'\nimport { mapGetters } from 'vuex'\n\nexport default {\n props: [\n 'user', 'switcher', 'selected', 'hideBio', 'rounded', 'bordered', 'allowZoomingAvatar'\n ],\n data () {\n return {\n followRequestInProgress: false,\n betterShadow: this.$store.state.interface.browserSupport.cssFilter\n }\n },\n created () {\n this.$store.dispatch('fetchUserRelationship', this.user.id)\n },\n computed: {\n classes () {\n return [{\n 'user-card-rounded-t': this.rounded === 'top', // set border-top-left-radius and border-top-right-radius\n 'user-card-rounded': this.rounded === true, // set border-radius for all sides\n 'user-card-bordered': this.bordered === true // set border for all sides\n }]\n },\n style () {\n const color = this.$store.getters.mergedConfig.customTheme.colors\n ? this.$store.getters.mergedConfig.customTheme.colors.bg // v2\n : this.$store.getters.mergedConfig.colors.bg // v1\n\n if (color) {\n const rgb = (typeof color === 'string') ? hex2rgb(color) : color\n const tintColor = `rgba(${Math.floor(rgb.r)}, ${Math.floor(rgb.g)}, ${Math.floor(rgb.b)}, .5)`\n\n return {\n backgroundColor: `rgb(${Math.floor(rgb.r * 0.53)}, ${Math.floor(rgb.g * 0.56)}, ${Math.floor(rgb.b * 0.59)})`,\n backgroundImage: [\n `linear-gradient(to bottom, ${tintColor}, ${tintColor})`,\n `url(${this.user.cover_photo})`\n ].join(', ')\n }\n }\n },\n isOtherUser () {\n return this.user.id !== this.$store.state.users.currentUser.id\n },\n subscribeUrl () {\n // eslint-disable-next-line no-undef\n const serverUrl = new URL(this.user.statusnet_profile_url)\n return `${serverUrl.protocol}//${serverUrl.host}/main/ostatus`\n },\n loggedIn () {\n return this.$store.state.users.currentUser\n },\n dailyAvg () {\n const days = Math.ceil((new Date() - new Date(this.user.created_at)) / (60 * 60 * 24 * 1000))\n return Math.round(this.user.statuses_count / days)\n },\n userHighlightType: {\n get () {\n const data = this.$store.getters.mergedConfig.highlight[this.user.screen_name]\n return (data && data.type) || 'disabled'\n },\n set (type) {\n const data = this.$store.getters.mergedConfig.highlight[this.user.screen_name]\n if (type !== 'disabled') {\n this.$store.dispatch('setHighlight', { user: this.user.screen_name, color: (data && data.color) || '#FFFFFF', type })\n } else {\n this.$store.dispatch('setHighlight', { user: this.user.screen_name, color: undefined })\n }\n },\n ...mapGetters(['mergedConfig'])\n },\n userHighlightColor: {\n get () {\n const data = this.$store.getters.mergedConfig.highlight[this.user.screen_name]\n return data && data.color\n },\n set (color) {\n this.$store.dispatch('setHighlight', { user: this.user.screen_name, color })\n }\n },\n visibleRole () {\n const rights = this.user.rights\n if (!rights) { return }\n const validRole = rights.admin || rights.moderator\n const roleTitle = rights.admin ? 'admin' : 'moderator'\n return validRole && roleTitle\n },\n ...mapGetters(['mergedConfig'])\n },\n components: {\n UserAvatar,\n RemoteFollow,\n ModerationTools,\n AccountActions,\n ProgressButton,\n FollowButton\n },\n methods: {\n muteUser () {\n this.$store.dispatch('muteUser', this.user.id)\n },\n unmuteUser () {\n this.$store.dispatch('unmuteUser', this.user.id)\n },\n subscribeUser () {\n return this.$store.dispatch('subscribeUser', this.user.id)\n },\n unsubscribeUser () {\n return this.$store.dispatch('unsubscribeUser', this.user.id)\n },\n setProfileView (v) {\n if (this.switcher) {\n const store = this.$store\n store.commit('setProfileView', { v })\n }\n },\n linkClicked ({ target }) {\n if (target.tagName === 'SPAN') {\n target = target.parentNode\n }\n if (target.tagName === 'A') {\n window.open(target.href, '_blank')\n }\n },\n userProfileLink (user) {\n return generateProfileLink(\n user.id, user.screen_name,\n this.$store.state.instance.restrictedNicknames\n )\n },\n zoomAvatar () {\n const attachment = {\n url: this.user.profile_image_url_original,\n mimetype: 'image'\n }\n this.$store.dispatch('setMedia', [attachment])\n this.$store.dispatch('setCurrent', attachment)\n }\n }\n}\n","import StillImage from '../still-image/still-image.vue'\n\nconst UserAvatar = {\n props: [\n 'user',\n 'betterShadow',\n 'compact'\n ],\n data () {\n return {\n showPlaceholder: false\n }\n },\n components: {\n StillImage\n },\n computed: {\n imgSrc () {\n return this.showPlaceholder ? '/images/avi.png' : this.user.profile_image_url_original\n }\n },\n methods: {\n imageLoadError () {\n this.showPlaceholder = true\n }\n },\n watch: {\n src () {\n this.showPlaceholder = false\n }\n }\n}\n\nexport default UserAvatar\n","export default {\n props: [ 'user' ],\n computed: {\n subscribeUrl () {\n // eslint-disable-next-line no-undef\n const serverUrl = new URL(this.user.statusnet_profile_url)\n return `${serverUrl.protocol}//${serverUrl.host}/main/ostatus`\n }\n }\n}\n","\n\n\n","import { requestFollow, requestUnfollow } from '../../services/follow_manipulate/follow_manipulate'\nexport default {\n props: ['user', 'labelFollowing', 'buttonClass'],\n data () {\n return {\n inProgress: false\n }\n },\n computed: {\n isPressed () {\n return this.inProgress || this.user.following\n },\n title () {\n if (this.inProgress || this.user.following) {\n return this.$t('user_card.follow_unfollow')\n } else if (this.user.requested) {\n return this.$t('user_card.follow_again')\n } else {\n return this.$t('user_card.follow')\n }\n },\n label () {\n if (this.inProgress) {\n return this.$t('user_card.follow_progress')\n } else if (this.user.following) {\n return this.labelFollowing || this.$t('user_card.following')\n } else if (this.user.requested) {\n return this.$t('user_card.follow_sent')\n } else {\n return this.$t('user_card.follow')\n }\n }\n },\n methods: {\n onClick () {\n this.user.following ? this.unfollow() : this.follow()\n },\n follow () {\n this.inProgress = true\n requestFollow(this.user, this.$store).then(() => {\n this.inProgress = false\n })\n },\n unfollow () {\n const store = this.$store\n this.inProgress = true\n requestUnfollow(this.user, store).then(() => {\n this.inProgress = false\n store.commit('removeStatus', { timeline: 'friends', userId: this.user.id })\n })\n }\n }\n}\n","import DialogModal from '../dialog_modal/dialog_modal.vue'\n\nconst FORCE_NSFW = 'mrf_tag:media-force-nsfw'\nconst STRIP_MEDIA = 'mrf_tag:media-strip'\nconst FORCE_UNLISTED = 'mrf_tag:force-unlisted'\nconst DISABLE_REMOTE_SUBSCRIPTION = 'mrf_tag:disable-remote-subscription'\nconst DISABLE_ANY_SUBSCRIPTION = 'mrf_tag:disable-any-subscription'\nconst SANDBOX = 'mrf_tag:sandbox'\nconst QUARANTINE = 'mrf_tag:quarantine'\n\nconst ModerationTools = {\n props: [\n 'user'\n ],\n data () {\n return {\n showDropDown: false,\n tags: {\n FORCE_NSFW,\n STRIP_MEDIA,\n FORCE_UNLISTED,\n DISABLE_REMOTE_SUBSCRIPTION,\n DISABLE_ANY_SUBSCRIPTION,\n SANDBOX,\n QUARANTINE\n },\n showDeleteUserDialog: false\n }\n },\n components: {\n DialogModal\n },\n computed: {\n tagsSet () {\n return new Set(this.user.tags)\n },\n hasTagPolicy () {\n return this.$store.state.instance.tagPolicyAvailable\n }\n },\n methods: {\n hasTag (tagName) {\n return this.tagsSet.has(tagName)\n },\n toggleTag (tag) {\n const store = this.$store\n if (this.tagsSet.has(tag)) {\n store.state.api.backendInteractor.untagUser(this.user, tag).then(response => {\n if (!response.ok) { return }\n store.commit('untagUser', { user: this.user, tag })\n })\n } else {\n store.state.api.backendInteractor.tagUser(this.user, tag).then(response => {\n if (!response.ok) { return }\n store.commit('tagUser', { user: this.user, tag })\n })\n }\n },\n toggleRight (right) {\n const store = this.$store\n if (this.user.rights[right]) {\n store.state.api.backendInteractor.deleteRight(this.user, right).then(response => {\n if (!response.ok) { return }\n store.commit('updateRight', { user: this.user, right: right, value: false })\n })\n } else {\n store.state.api.backendInteractor.addRight(this.user, right).then(response => {\n if (!response.ok) { return }\n store.commit('updateRight', { user: this.user, right: right, value: true })\n })\n }\n },\n toggleActivationStatus () {\n const store = this.$store\n const status = !!this.user.deactivated\n store.state.api.backendInteractor.setActivationStatus(this.user, status).then(response => {\n if (!response.ok) { return }\n store.commit('updateActivationStatus', { user: this.user, status: status })\n })\n },\n deleteUserDialog (show) {\n this.showDeleteUserDialog = show\n },\n deleteUser () {\n const store = this.$store\n const user = this.user\n const { id, name } = user\n store.state.api.backendInteractor.deleteUser(user)\n .then(e => {\n this.$store.dispatch('markStatusesAsDeleted', status => user.id === status.user.id)\n const isProfile = this.$route.name === 'external-user-profile' || this.$route.name === 'user-profile'\n const isTargetUser = this.$route.params.name === name || this.$route.params.id === id\n if (isProfile && isTargetUser) {\n window.history.back()\n }\n })\n }\n }\n}\n\nexport default ModerationTools\n","const DialogModal = {\n props: {\n darkOverlay: {\n default: true,\n type: Boolean\n },\n onCancel: {\n default: () => {},\n type: Function\n }\n }\n}\n\nexport default DialogModal\n","import ProgressButton from '../progress_button/progress_button.vue'\n\nconst AccountActions = {\n props: [\n 'user'\n ],\n data () {\n return { }\n },\n components: {\n ProgressButton\n },\n methods: {\n showRepeats () {\n this.$store.dispatch('showReblogs', this.user.id)\n },\n hideRepeats () {\n this.$store.dispatch('hideReblogs', this.user.id)\n },\n blockUser () {\n this.$store.dispatch('blockUser', this.user.id)\n },\n unblockUser () {\n this.$store.dispatch('unblockUser', this.user.id)\n },\n reportUser () {\n this.$store.dispatch('openUserReportingModal', this.user.id)\n },\n mentionUser () {\n this.$store.dispatch('openPostStatusModal', { replyTo: true, repliedUser: this.user })\n }\n }\n}\n\nexport default AccountActions\n","import Attachment from '../attachment/attachment.vue'\nimport { chunk, last, dropRight, sumBy } from 'lodash'\n\nconst Gallery = {\n props: [\n 'attachments',\n 'nsfw',\n 'setMedia'\n ],\n data () {\n return {\n sizes: {}\n }\n },\n components: { Attachment },\n computed: {\n rows () {\n if (!this.attachments) {\n return []\n }\n const rows = chunk(this.attachments, 3)\n if (last(rows).length === 1 && rows.length > 1) {\n // if 1 attachment on last row -> add it to the previous row instead\n const lastAttachment = last(rows)[0]\n const allButLastRow = dropRight(rows)\n last(allButLastRow).push(lastAttachment)\n return allButLastRow\n }\n return rows\n },\n useContainFit () {\n return this.$store.getters.mergedConfig.useContainFit\n }\n },\n methods: {\n onNaturalSizeLoad (id, size) {\n this.$set(this.sizes, id, size)\n },\n rowStyle (itemsPerRow) {\n return { 'padding-bottom': `${(100 / (itemsPerRow + 0.6))}%` }\n },\n itemStyle (id, row) {\n const total = sumBy(row, item => this.getAspectRatio(item.id))\n return { flex: `${this.getAspectRatio(id) / total} 1 0%` }\n },\n getAspectRatio (id) {\n const size = this.sizes[id]\n return size ? size.width / size.height : 1\n }\n }\n}\n\nexport default Gallery\n","const LinkPreview = {\n name: 'LinkPreview',\n props: [\n 'card',\n 'size',\n 'nsfw'\n ],\n data () {\n return {\n imageLoaded: false\n }\n },\n computed: {\n useImage () {\n // Currently BE shoudn't give cards if tagged NSFW, this is a bit paranoid\n // as it makes sure to hide the image if somehow NSFW tagged preview can\n // exist.\n return this.card.image && !this.nsfw && this.size !== 'hide'\n },\n useDescription () {\n return this.card.description && /\\S/.test(this.card.description)\n }\n },\n created () {\n if (this.useImage) {\n const newImg = new Image()\n newImg.onload = () => {\n this.imageLoaded = true\n }\n newImg.src = this.card.image\n }\n }\n}\n\nexport default LinkPreview\n","import UserAvatar from '../user_avatar/user_avatar.vue'\nimport generateProfileLink from 'src/services/user_profile_link_generator/user_profile_link_generator'\n\nconst AvatarList = {\n props: ['users'],\n computed: {\n slicedUsers () {\n return this.users ? this.users.slice(0, 15) : []\n }\n },\n components: {\n UserAvatar\n },\n methods: {\n userProfileLink (user) {\n return generateProfileLink(user.id, user.screen_name, this.$store.state.instance.restrictedNicknames)\n }\n }\n}\n\nexport default AvatarList\n","import { find } from 'lodash'\n\nconst StatusPopover = {\n name: 'StatusPopover',\n props: [\n 'statusId'\n ],\n data () {\n return {\n popperOptions: {\n modifiers: {\n preventOverflow: { padding: { top: 50 }, boundariesElement: 'viewport' }\n }\n }\n }\n },\n computed: {\n status () {\n return find(this.$store.state.statuses.allStatuses, { id: this.statusId })\n }\n },\n components: {\n Status: () => import('../status/status.vue')\n },\n methods: {\n enter () {\n if (!this.status) {\n this.$store.dispatch('fetchStatus', this.statusId)\n }\n }\n }\n}\n\nexport default StatusPopover\n","import { reduce, filter, findIndex, clone, get } from 'lodash'\nimport Status from '../status/status.vue'\n\nconst sortById = (a, b) => {\n const idA = a.type === 'retweet' ? a.retweeted_status.id : a.id\n const idB = b.type === 'retweet' ? b.retweeted_status.id : b.id\n const seqA = Number(idA)\n const seqB = Number(idB)\n const isSeqA = !Number.isNaN(seqA)\n const isSeqB = !Number.isNaN(seqB)\n if (isSeqA && isSeqB) {\n return seqA < seqB ? -1 : 1\n } else if (isSeqA && !isSeqB) {\n return -1\n } else if (!isSeqA && isSeqB) {\n return 1\n } else {\n return idA < idB ? -1 : 1\n }\n}\n\nconst sortAndFilterConversation = (conversation, statusoid) => {\n if (statusoid.type === 'retweet') {\n conversation = filter(\n conversation,\n (status) => (status.type === 'retweet' || status.id !== statusoid.retweeted_status.id)\n )\n } else {\n conversation = filter(conversation, (status) => status.type !== 'retweet')\n }\n return conversation.filter(_ => _).sort(sortById)\n}\n\nconst conversation = {\n data () {\n return {\n highlight: null,\n expanded: false\n }\n },\n props: [\n 'statusId',\n 'collapsable',\n 'isPage',\n 'pinnedStatusIdsObject',\n 'inProfile'\n ],\n created () {\n if (this.isPage) {\n this.fetchConversation()\n }\n },\n computed: {\n status () {\n return this.$store.state.statuses.allStatusesObject[this.statusId]\n },\n originalStatusId () {\n if (this.status.retweeted_status) {\n return this.status.retweeted_status.id\n } else {\n return this.statusId\n }\n },\n conversationId () {\n return this.getConversationId(this.statusId)\n },\n conversation () {\n if (!this.status) {\n return []\n }\n\n if (!this.isExpanded) {\n return [this.status]\n }\n\n const conversation = clone(this.$store.state.statuses.conversationsObject[this.conversationId])\n const statusIndex = findIndex(conversation, { id: this.originalStatusId })\n if (statusIndex !== -1) {\n conversation[statusIndex] = this.status\n }\n\n return sortAndFilterConversation(conversation, this.status)\n },\n replies () {\n let i = 1\n // eslint-disable-next-line camelcase\n return reduce(this.conversation, (result, { id, in_reply_to_status_id }) => {\n /* eslint-disable camelcase */\n const irid = in_reply_to_status_id\n /* eslint-enable camelcase */\n if (irid) {\n result[irid] = result[irid] || []\n result[irid].push({\n name: `#${i}`,\n id: id\n })\n }\n i++\n return result\n }, {})\n },\n isExpanded () {\n return this.expanded || this.isPage\n }\n },\n components: {\n Status\n },\n watch: {\n statusId (newVal, oldVal) {\n const newConversationId = this.getConversationId(newVal)\n const oldConversationId = this.getConversationId(oldVal)\n if (newConversationId && oldConversationId && newConversationId === oldConversationId) {\n this.setHighlight(this.originalStatusId)\n } else {\n this.fetchConversation()\n }\n },\n expanded (value) {\n if (value) {\n this.fetchConversation()\n }\n }\n },\n methods: {\n fetchConversation () {\n if (this.status) {\n this.$store.state.api.backendInteractor.fetchConversation({ id: this.statusId })\n .then(({ ancestors, descendants }) => {\n this.$store.dispatch('addNewStatuses', { statuses: ancestors })\n this.$store.dispatch('addNewStatuses', { statuses: descendants })\n this.setHighlight(this.originalStatusId)\n })\n } else {\n this.$store.state.api.backendInteractor.fetchStatus({ id: this.statusId })\n .then((status) => {\n this.$store.dispatch('addNewStatuses', { statuses: [status] })\n this.fetchConversation()\n })\n }\n },\n getReplies (id) {\n return this.replies[id] || []\n },\n focused (id) {\n return (this.isExpanded) && id === this.statusId\n },\n setHighlight (id) {\n if (!id) return\n this.highlight = id\n this.$store.dispatch('fetchFavsAndRepeats', id)\n },\n getHighlight () {\n return this.isExpanded ? this.highlight : null\n },\n toggleExpanded () {\n this.expanded = !this.expanded\n },\n getConversationId (statusId) {\n const status = this.$store.state.statuses.allStatusesObject[statusId]\n return get(status, 'retweeted_status.statusnet_conversation_id', get(status, 'statusnet_conversation_id'))\n }\n }\n}\n\nexport default conversation\n","import Timeline from '../timeline/timeline.vue'\nconst PublicAndExternalTimeline = {\n components: {\n Timeline\n },\n computed: {\n timeline () { return this.$store.state.statuses.timelines.publicAndExternal }\n },\n created () {\n this.$store.dispatch('startFetchingTimeline', { timeline: 'publicAndExternal' })\n },\n destroyed () {\n this.$store.dispatch('stopFetching', 'publicAndExternal')\n }\n}\n\nexport default PublicAndExternalTimeline\n","import Timeline from '../timeline/timeline.vue'\nconst FriendsTimeline = {\n components: {\n Timeline\n },\n computed: {\n timeline () { return this.$store.state.statuses.timelines.friends }\n }\n}\n\nexport default FriendsTimeline\n","import Timeline from '../timeline/timeline.vue'\n\nconst TagTimeline = {\n created () {\n this.$store.commit('clearTimeline', { timeline: 'tag' })\n this.$store.dispatch('startFetchingTimeline', { timeline: 'tag', tag: this.tag })\n },\n components: {\n Timeline\n },\n computed: {\n tag () { return this.$route.params.tag },\n timeline () { return this.$store.state.statuses.timelines.tag }\n },\n watch: {\n tag () {\n this.$store.commit('clearTimeline', { timeline: 'tag' })\n this.$store.dispatch('startFetchingTimeline', { timeline: 'tag', tag: this.tag })\n }\n },\n destroyed () {\n this.$store.dispatch('stopFetching', 'tag')\n }\n}\n\nexport default TagTimeline\n","import Conversation from '../conversation/conversation.vue'\n\nconst conversationPage = {\n components: {\n Conversation\n },\n computed: {\n statusId () {\n return this.$route.params.id\n }\n }\n}\n\nexport default conversationPage\n","import Notifications from '../notifications/notifications.vue'\n\nconst tabModeDict = {\n mentions: ['mention'],\n 'likes+repeats': ['repeat', 'like'],\n follows: ['follow']\n}\n\nconst Interactions = {\n data () {\n return {\n filterMode: tabModeDict['mentions']\n }\n },\n methods: {\n onModeSwitch (key) {\n this.filterMode = tabModeDict[key]\n }\n },\n components: {\n Notifications\n }\n}\n\nexport default Interactions\n","import Notification from '../notification/notification.vue'\nimport notificationsFetcher from '../../services/notifications_fetcher/notifications_fetcher.service.js'\nimport {\n notificationsFromStore,\n visibleNotificationsFromStore,\n unseenNotificationsFromStore\n} from '../../services/notification_utils/notification_utils.js'\n\nconst Notifications = {\n props: {\n // Disables display of panel header\n noHeading: Boolean,\n // Disables panel styles, unread mark, potentially other notification-related actions\n // meant for \"Interactions\" timeline\n minimalMode: Boolean,\n // Custom filter mode, an array of strings, possible values 'mention', 'repeat', 'like', 'follow', used to override global filter for use in \"Interactions\" timeline\n filterMode: Array\n },\n data () {\n return {\n bottomedOut: false\n }\n },\n computed: {\n mainClass () {\n return this.minimalMode ? '' : 'panel panel-default'\n },\n notifications () {\n return notificationsFromStore(this.$store)\n },\n error () {\n return this.$store.state.statuses.notifications.error\n },\n unseenNotifications () {\n return unseenNotificationsFromStore(this.$store)\n },\n visibleNotifications () {\n return visibleNotificationsFromStore(this.$store, this.filterMode)\n },\n unseenCount () {\n return this.unseenNotifications.length\n },\n loading () {\n return this.$store.state.statuses.notifications.loading\n }\n },\n components: {\n Notification\n },\n watch: {\n unseenCount (count) {\n if (count > 0) {\n this.$store.dispatch('setPageTitle', `(${count})`)\n } else {\n this.$store.dispatch('setPageTitle', '')\n }\n }\n },\n methods: {\n markAsSeen () {\n this.$store.dispatch('markNotificationsAsSeen')\n },\n fetchOlderNotifications () {\n if (this.loading) {\n return\n }\n\n const store = this.$store\n const credentials = store.state.users.currentUser.credentials\n store.commit('setNotificationsLoading', { value: true })\n notificationsFetcher.fetchAndUpdate({\n store,\n credentials,\n older: true\n }).then(notifs => {\n store.commit('setNotificationsLoading', { value: false })\n if (notifs.length === 0) {\n this.bottomedOut = true\n }\n })\n }\n }\n}\n\nexport default Notifications\n","import Status from '../status/status.vue'\nimport UserAvatar from '../user_avatar/user_avatar.vue'\nimport UserCard from '../user_card/user_card.vue'\nimport Timeago from '../timeago/timeago.vue'\nimport { highlightClass, highlightStyle } from '../../services/user_highlighter/user_highlighter.js'\nimport generateProfileLink from 'src/services/user_profile_link_generator/user_profile_link_generator'\n\nconst Notification = {\n data () {\n return {\n userExpanded: false,\n betterShadow: this.$store.state.interface.browserSupport.cssFilter,\n unmuted: false\n }\n },\n props: [ 'notification' ],\n components: {\n Status,\n UserAvatar,\n UserCard,\n Timeago\n },\n methods: {\n toggleUserExpanded () {\n this.userExpanded = !this.userExpanded\n },\n generateUserProfileLink (user) {\n return generateProfileLink(user.id, user.screen_name, this.$store.state.instance.restrictedNicknames)\n },\n getUser (notification) {\n return this.$store.state.users.usersObject[notification.from_profile.id]\n },\n toggleMute () {\n this.unmuted = !this.unmuted\n }\n },\n computed: {\n userClass () {\n return highlightClass(this.notification.from_profile)\n },\n userStyle () {\n const highlight = this.$store.getters.mergedConfig.highlight\n const user = this.notification.from_profile\n return highlightStyle(highlight[user.screen_name])\n },\n userInStore () {\n return this.$store.getters.findUser(this.notification.from_profile.id)\n },\n user () {\n if (this.userInStore) {\n return this.userInStore\n }\n return this.notification.from_profile\n },\n userProfileLink () {\n return this.generateUserProfileLink(this.user)\n },\n needMute () {\n return this.user.muted\n }\n }\n}\n\nexport default Notification\n","import Timeline from '../timeline/timeline.vue'\n\nconst DMs = {\n computed: {\n timeline () {\n return this.$store.state.statuses.timelines.dms\n }\n },\n components: {\n Timeline\n }\n}\n\nexport default DMs\n","import get from 'lodash/get'\nimport UserCard from '../user_card/user_card.vue'\nimport FollowCard from '../follow_card/follow_card.vue'\nimport Timeline from '../timeline/timeline.vue'\nimport Conversation from '../conversation/conversation.vue'\nimport List from '../list/list.vue'\nimport withLoadMore from '../../hocs/with_load_more/with_load_more'\n\nconst FollowerList = withLoadMore({\n fetch: (props, $store) => $store.dispatch('fetchFollowers', props.userId),\n select: (props, $store) => get($store.getters.findUser(props.userId), 'followerIds', []).map(id => $store.getters.findUser(id)),\n destroy: (props, $store) => $store.dispatch('clearFollowers', props.userId),\n childPropName: 'items',\n additionalPropNames: ['userId']\n})(List)\n\nconst FriendList = withLoadMore({\n fetch: (props, $store) => $store.dispatch('fetchFriends', props.userId),\n select: (props, $store) => get($store.getters.findUser(props.userId), 'friendIds', []).map(id => $store.getters.findUser(id)),\n destroy: (props, $store) => $store.dispatch('clearFriends', props.userId),\n childPropName: 'items',\n additionalPropNames: ['userId']\n})(List)\n\nconst defaultTabKey = 'statuses'\n\nconst UserProfile = {\n data () {\n return {\n error: false,\n userId: null,\n tab: defaultTabKey\n }\n },\n created () {\n const routeParams = this.$route.params\n this.load(routeParams.name || routeParams.id)\n this.tab = get(this.$route, 'query.tab', defaultTabKey)\n },\n destroyed () {\n this.stopFetching()\n },\n computed: {\n timeline () {\n return this.$store.state.statuses.timelines.user\n },\n favorites () {\n return this.$store.state.statuses.timelines.favorites\n },\n media () {\n return this.$store.state.statuses.timelines.media\n },\n isUs () {\n return this.userId && this.$store.state.users.currentUser.id &&\n this.userId === this.$store.state.users.currentUser.id\n },\n user () {\n return this.$store.getters.findUser(this.userId)\n },\n isExternal () {\n return this.$route.name === 'external-user-profile'\n },\n followsTabVisible () {\n return this.isUs || !this.user.hide_follows\n },\n followersTabVisible () {\n return this.isUs || !this.user.hide_followers\n }\n },\n methods: {\n load (userNameOrId) {\n const startFetchingTimeline = (timeline, userId) => {\n // Clear timeline only if load another user's profile\n if (userId !== this.$store.state.statuses.timelines[timeline].userId) {\n this.$store.commit('clearTimeline', { timeline })\n }\n this.$store.dispatch('startFetchingTimeline', { timeline, userId })\n }\n\n const loadById = (userId) => {\n this.userId = userId\n startFetchingTimeline('user', userId)\n startFetchingTimeline('media', userId)\n if (this.isUs) {\n startFetchingTimeline('favorites', userId)\n }\n // Fetch all pinned statuses immediately\n this.$store.dispatch('fetchPinnedStatuses', userId)\n }\n\n // Reset view\n this.userId = null\n this.error = false\n\n // Check if user data is already loaded in store\n const user = this.$store.getters.findUser(userNameOrId)\n if (user) {\n loadById(user.id)\n } else {\n this.$store.dispatch('fetchUser', userNameOrId)\n .then(({ id }) => loadById(id))\n .catch((reason) => {\n const errorMessage = get(reason, 'error.error')\n if (errorMessage === 'No user with such user_id') { // Known error\n this.error = this.$t('user_profile.profile_does_not_exist')\n } else if (errorMessage) {\n this.error = errorMessage\n } else {\n this.error = this.$t('user_profile.profile_loading_error')\n }\n })\n }\n },\n stopFetching () {\n this.$store.dispatch('stopFetching', 'user')\n this.$store.dispatch('stopFetching', 'favorites')\n this.$store.dispatch('stopFetching', 'media')\n },\n switchUser (userNameOrId) {\n this.stopFetching()\n this.load(userNameOrId)\n },\n onTabSwitch (tab) {\n this.tab = tab\n this.$router.replace({ query: { tab } })\n }\n },\n watch: {\n '$route.params.id': function (newVal) {\n if (newVal) {\n this.switchUser(newVal)\n }\n },\n '$route.params.name': function (newVal) {\n if (newVal) {\n this.switchUser(newVal)\n }\n },\n '$route.query': function (newVal) {\n this.tab = newVal.tab || defaultTabKey\n }\n },\n components: {\n UserCard,\n Timeline,\n FollowerList,\n FriendList,\n FollowCard,\n Conversation\n }\n}\n\nexport default UserProfile\n","import BasicUserCard from '../basic_user_card/basic_user_card.vue'\nimport RemoteFollow from '../remote_follow/remote_follow.vue'\nimport FollowButton from '../follow_button/follow_button.vue'\n\nconst FollowCard = {\n props: [\n 'user',\n 'noFollowsYou'\n ],\n components: {\n BasicUserCard,\n RemoteFollow,\n FollowButton\n },\n computed: {\n isMe () {\n return this.$store.state.users.currentUser.id === this.user.id\n },\n loggedIn () {\n return this.$store.state.users.currentUser\n }\n }\n}\n\nexport default FollowCard\n","import UserCard from '../user_card/user_card.vue'\nimport UserAvatar from '../user_avatar/user_avatar.vue'\nimport generateProfileLink from 'src/services/user_profile_link_generator/user_profile_link_generator'\n\nconst BasicUserCard = {\n props: [\n 'user'\n ],\n data () {\n return {\n userExpanded: false\n }\n },\n components: {\n UserCard,\n UserAvatar\n },\n methods: {\n toggleUserExpanded () {\n this.userExpanded = !this.userExpanded\n },\n userProfileLink (user) {\n return generateProfileLink(user.id, user.screen_name, this.$store.state.instance.restrictedNicknames)\n }\n }\n}\n\nexport default BasicUserCard\n","\n\n\n\n\n","import FollowCard from '../follow_card/follow_card.vue'\nimport Conversation from '../conversation/conversation.vue'\nimport Status from '../status/status.vue'\nimport map from 'lodash/map'\n\nconst Search = {\n components: {\n FollowCard,\n Conversation,\n Status\n },\n props: [\n 'query'\n ],\n data () {\n return {\n loaded: false,\n loading: false,\n searchTerm: this.query || '',\n userIds: [],\n statuses: [],\n hashtags: [],\n currenResultTab: 'statuses'\n }\n },\n computed: {\n users () {\n return this.userIds.map(userId => this.$store.getters.findUser(userId))\n },\n visibleStatuses () {\n const allStatusesObject = this.$store.state.statuses.allStatusesObject\n\n return this.statuses.filter(status =>\n allStatusesObject[status.id] && !allStatusesObject[status.id].deleted\n )\n }\n },\n mounted () {\n this.search(this.query)\n },\n watch: {\n query (newValue) {\n this.searchTerm = newValue\n this.search(newValue)\n }\n },\n methods: {\n newQuery (query) {\n this.$router.push({ name: 'search', query: { query } })\n this.$refs.searchInput.focus()\n },\n search (query) {\n if (!query) {\n this.loading = false\n return\n }\n\n this.loading = true\n this.userIds = []\n this.statuses = []\n this.hashtags = []\n this.$refs.searchInput.blur()\n\n this.$store.dispatch('search', { q: query, resolve: true })\n .then(data => {\n this.loading = false\n this.userIds = map(data.accounts, 'id')\n this.statuses = data.statuses\n this.hashtags = data.hashtags\n this.currenResultTab = this.getActiveTab()\n this.loaded = true\n })\n },\n resultCount (tabName) {\n const length = this[tabName].length\n return length === 0 ? '' : ` (${length})`\n },\n onResultTabSwitch (key) {\n this.currenResultTab = key\n },\n getActiveTab () {\n if (this.visibleStatuses.length > 0) {\n return 'statuses'\n } else if (this.users.length > 0) {\n return 'people'\n } else if (this.hashtags.length > 0) {\n return 'hashtags'\n }\n\n return 'statuses'\n },\n lastHistoryRecord (hashtag) {\n return hashtag.history && hashtag.history[0]\n }\n }\n}\n\nexport default Search\n","/* eslint-env browser */\nimport { filter, trim } from 'lodash'\n\nimport TabSwitcher from '../tab_switcher/tab_switcher.js'\nimport StyleSwitcher from '../style_switcher/style_switcher.vue'\nimport InterfaceLanguageSwitcher from '../interface_language_switcher/interface_language_switcher.vue'\nimport { extractCommit } from '../../services/version/version.service'\nimport { instanceDefaultProperties, defaultState as configDefaultState } from '../../modules/config.js'\nimport Checkbox from '../checkbox/checkbox.vue'\n\nconst pleromaFeCommitUrl = 'https://git.pleroma.social/pleroma/pleroma-fe/commit/'\nconst pleromaBeCommitUrl = 'https://git.pleroma.social/pleroma/pleroma/commit/'\n\nconst multiChoiceProperties = [\n 'postContentType',\n 'subjectLineBehavior'\n]\n\nconst settings = {\n data () {\n const instance = this.$store.state.instance\n\n return {\n loopSilentAvailable:\n // Firefox\n Object.getOwnPropertyDescriptor(HTMLVideoElement.prototype, 'mozHasAudio') ||\n // Chrome-likes\n Object.getOwnPropertyDescriptor(HTMLMediaElement.prototype, 'webkitAudioDecodedByteCount') ||\n // Future spec, still not supported in Nightly 63 as of 08/2018\n Object.getOwnPropertyDescriptor(HTMLMediaElement.prototype, 'audioTracks'),\n\n backendVersion: instance.backendVersion,\n frontendVersion: instance.frontendVersion\n }\n },\n components: {\n TabSwitcher,\n StyleSwitcher,\n InterfaceLanguageSwitcher,\n Checkbox\n },\n computed: {\n user () {\n return this.$store.state.users.currentUser\n },\n currentSaveStateNotice () {\n return this.$store.state.interface.settings.currentSaveStateNotice\n },\n postFormats () {\n return this.$store.state.instance.postFormats || []\n },\n instanceSpecificPanelPresent () { return this.$store.state.instance.showInstanceSpecificPanel },\n frontendVersionLink () {\n return pleromaFeCommitUrl + this.frontendVersion\n },\n backendVersionLink () {\n return pleromaBeCommitUrl + extractCommit(this.backendVersion)\n },\n // Getting localized values for instance-default properties\n ...instanceDefaultProperties\n .filter(key => multiChoiceProperties.includes(key))\n .map(key => [\n key + 'DefaultValue',\n function () {\n return this.$store.getters.instanceDefaultConfig[key]\n }\n ])\n .reduce((acc, [key, value]) => ({ ...acc, [key]: value }), {}),\n ...instanceDefaultProperties\n .filter(key => !multiChoiceProperties.includes(key))\n .map(key => [\n key + 'LocalizedValue',\n function () {\n return this.$t('settings.values.' + this.$store.getters.instanceDefaultConfig[key])\n }\n ])\n .reduce((acc, [key, value]) => ({ ...acc, [key]: value }), {}),\n // Generating computed values for vuex properties\n ...Object.keys(configDefaultState)\n .map(key => [key, {\n get () { return this.$store.getters.mergedConfig[key] },\n set (value) {\n this.$store.dispatch('setOption', { name: key, value })\n }\n }])\n .reduce((acc, [key, value]) => ({ ...acc, [key]: value }), {}),\n // Special cases (need to transform values)\n muteWordsString: {\n get () { return this.$store.getters.mergedConfig.muteWords.join('\\n') },\n set (value) {\n this.$store.dispatch('setOption', {\n name: 'muteWords',\n value: filter(value.split('\\n'), (word) => trim(word).length > 0)\n })\n }\n }\n },\n // Updating nested properties\n watch: {\n notificationVisibility: {\n handler (value) {\n this.$store.dispatch('setOption', {\n name: 'notificationVisibility',\n value: this.$store.getters.mergedConfig.notificationVisibility\n })\n },\n deep: true\n }\n }\n}\n\nexport default settings\n","import { rgb2hex, hex2rgb, getContrastRatio, alphaBlend } from '../../services/color_convert/color_convert.js'\nimport { set, delete as del } from 'vue'\nimport { generateColors, generateShadows, generateRadii, generateFonts, composePreset, getThemes } from '../../services/style_setter/style_setter.js'\nimport ColorInput from '../color_input/color_input.vue'\nimport RangeInput from '../range_input/range_input.vue'\nimport OpacityInput from '../opacity_input/opacity_input.vue'\nimport ShadowControl from '../shadow_control/shadow_control.vue'\nimport FontControl from '../font_control/font_control.vue'\nimport ContrastRatio from '../contrast_ratio/contrast_ratio.vue'\nimport TabSwitcher from '../tab_switcher/tab_switcher.js'\nimport Preview from './preview.vue'\nimport ExportImport from '../export_import/export_import.vue'\nimport Checkbox from '../checkbox/checkbox.vue'\n\n// List of color values used in v1\nconst v1OnlyNames = [\n 'bg',\n 'fg',\n 'text',\n 'link',\n 'cRed',\n 'cGreen',\n 'cBlue',\n 'cOrange'\n].map(_ => _ + 'ColorLocal')\n\nexport default {\n data () {\n return {\n availableStyles: [],\n selected: this.$store.getters.mergedConfig.theme,\n\n previewShadows: {},\n previewColors: {},\n previewRadii: {},\n previewFonts: {},\n\n shadowsInvalid: true,\n colorsInvalid: true,\n radiiInvalid: true,\n\n keepColor: false,\n keepShadows: false,\n keepOpacity: false,\n keepRoundness: false,\n keepFonts: false,\n\n textColorLocal: '',\n linkColorLocal: '',\n\n bgColorLocal: '',\n bgOpacityLocal: undefined,\n\n fgColorLocal: '',\n fgTextColorLocal: undefined,\n fgLinkColorLocal: undefined,\n\n btnColorLocal: undefined,\n btnTextColorLocal: undefined,\n btnOpacityLocal: undefined,\n\n inputColorLocal: undefined,\n inputTextColorLocal: undefined,\n inputOpacityLocal: undefined,\n\n panelColorLocal: undefined,\n panelTextColorLocal: undefined,\n panelLinkColorLocal: undefined,\n panelFaintColorLocal: undefined,\n panelOpacityLocal: undefined,\n\n topBarColorLocal: undefined,\n topBarTextColorLocal: undefined,\n topBarLinkColorLocal: undefined,\n\n alertErrorColorLocal: undefined,\n alertWarningColorLocal: undefined,\n\n badgeOpacityLocal: undefined,\n badgeNotificationColorLocal: undefined,\n\n borderColorLocal: undefined,\n borderOpacityLocal: undefined,\n\n faintColorLocal: undefined,\n faintOpacityLocal: undefined,\n faintLinkColorLocal: undefined,\n\n cRedColorLocal: '',\n cBlueColorLocal: '',\n cGreenColorLocal: '',\n cOrangeColorLocal: '',\n\n shadowSelected: undefined,\n shadowsLocal: {},\n fontsLocal: {},\n\n btnRadiusLocal: '',\n inputRadiusLocal: '',\n checkboxRadiusLocal: '',\n panelRadiusLocal: '',\n avatarRadiusLocal: '',\n avatarAltRadiusLocal: '',\n attachmentRadiusLocal: '',\n tooltipRadiusLocal: ''\n }\n },\n created () {\n const self = this\n\n getThemes().then((themesComplete) => {\n self.availableStyles = themesComplete\n })\n },\n mounted () {\n this.normalizeLocalState(this.$store.getters.mergedConfig.customTheme)\n if (typeof this.shadowSelected === 'undefined') {\n this.shadowSelected = this.shadowsAvailable[0]\n }\n },\n computed: {\n selectedVersion () {\n return Array.isArray(this.selected) ? 1 : 2\n },\n currentColors () {\n return {\n bg: this.bgColorLocal,\n text: this.textColorLocal,\n link: this.linkColorLocal,\n\n fg: this.fgColorLocal,\n fgText: this.fgTextColorLocal,\n fgLink: this.fgLinkColorLocal,\n\n panel: this.panelColorLocal,\n panelText: this.panelTextColorLocal,\n panelLink: this.panelLinkColorLocal,\n panelFaint: this.panelFaintColorLocal,\n\n input: this.inputColorLocal,\n inputText: this.inputTextColorLocal,\n\n topBar: this.topBarColorLocal,\n topBarText: this.topBarTextColorLocal,\n topBarLink: this.topBarLinkColorLocal,\n\n btn: this.btnColorLocal,\n btnText: this.btnTextColorLocal,\n\n alertError: this.alertErrorColorLocal,\n alertWarning: this.alertWarningColorLocal,\n badgeNotification: this.badgeNotificationColorLocal,\n\n faint: this.faintColorLocal,\n faintLink: this.faintLinkColorLocal,\n border: this.borderColorLocal,\n\n cRed: this.cRedColorLocal,\n cBlue: this.cBlueColorLocal,\n cGreen: this.cGreenColorLocal,\n cOrange: this.cOrangeColorLocal\n }\n },\n currentOpacity () {\n return {\n bg: this.bgOpacityLocal,\n btn: this.btnOpacityLocal,\n input: this.inputOpacityLocal,\n panel: this.panelOpacityLocal,\n topBar: this.topBarOpacityLocal,\n border: this.borderOpacityLocal,\n faint: this.faintOpacityLocal\n }\n },\n currentRadii () {\n return {\n btn: this.btnRadiusLocal,\n input: this.inputRadiusLocal,\n checkbox: this.checkboxRadiusLocal,\n panel: this.panelRadiusLocal,\n avatar: this.avatarRadiusLocal,\n avatarAlt: this.avatarAltRadiusLocal,\n tooltip: this.tooltipRadiusLocal,\n attachment: this.attachmentRadiusLocal\n }\n },\n preview () {\n return composePreset(this.previewColors, this.previewRadii, this.previewShadows, this.previewFonts)\n },\n previewTheme () {\n if (!this.preview.theme.colors) return { colors: {}, opacity: {}, radii: {}, shadows: {}, fonts: {} }\n return this.preview.theme\n },\n // This needs optimization maybe\n previewContrast () {\n if (!this.previewTheme.colors.bg) return {}\n const colors = this.previewTheme.colors\n const opacity = this.previewTheme.opacity\n if (!colors.bg) return {}\n const hints = (ratio) => ({\n text: ratio.toPrecision(3) + ':1',\n // AA level, AAA level\n aa: ratio >= 4.5,\n aaa: ratio >= 7,\n // same but for 18pt+ texts\n laa: ratio >= 3,\n laaa: ratio >= 4.5\n })\n\n // fgsfds :DDDD\n const fgs = {\n text: hex2rgb(colors.text),\n panelText: hex2rgb(colors.panelText),\n panelLink: hex2rgb(colors.panelLink),\n btnText: hex2rgb(colors.btnText),\n topBarText: hex2rgb(colors.topBarText),\n inputText: hex2rgb(colors.inputText),\n\n link: hex2rgb(colors.link),\n topBarLink: hex2rgb(colors.topBarLink),\n\n red: hex2rgb(colors.cRed),\n green: hex2rgb(colors.cGreen),\n blue: hex2rgb(colors.cBlue),\n orange: hex2rgb(colors.cOrange)\n }\n\n const bgs = {\n bg: hex2rgb(colors.bg),\n btn: hex2rgb(colors.btn),\n panel: hex2rgb(colors.panel),\n topBar: hex2rgb(colors.topBar),\n input: hex2rgb(colors.input),\n alertError: hex2rgb(colors.alertError),\n alertWarning: hex2rgb(colors.alertWarning),\n badgeNotification: hex2rgb(colors.badgeNotification)\n }\n\n /* This is a bit confusing because \"bottom layer\" used is text color\n * This is done to get worst case scenario when background below transparent\n * layer matches text color, making it harder to read the lower alpha is.\n */\n const ratios = {\n bgText: getContrastRatio(alphaBlend(bgs.bg, opacity.bg, fgs.text), fgs.text),\n bgLink: getContrastRatio(alphaBlend(bgs.bg, opacity.bg, fgs.link), fgs.link),\n bgRed: getContrastRatio(alphaBlend(bgs.bg, opacity.bg, fgs.red), fgs.red),\n bgGreen: getContrastRatio(alphaBlend(bgs.bg, opacity.bg, fgs.green), fgs.green),\n bgBlue: getContrastRatio(alphaBlend(bgs.bg, opacity.bg, fgs.blue), fgs.blue),\n bgOrange: getContrastRatio(alphaBlend(bgs.bg, opacity.bg, fgs.orange), fgs.orange),\n\n tintText: getContrastRatio(alphaBlend(bgs.bg, 0.5, fgs.panelText), fgs.text),\n\n panelText: getContrastRatio(alphaBlend(bgs.panel, opacity.panel, fgs.panelText), fgs.panelText),\n panelLink: getContrastRatio(alphaBlend(bgs.panel, opacity.panel, fgs.panelLink), fgs.panelLink),\n\n btnText: getContrastRatio(alphaBlend(bgs.btn, opacity.btn, fgs.btnText), fgs.btnText),\n\n inputText: getContrastRatio(alphaBlend(bgs.input, opacity.input, fgs.inputText), fgs.inputText),\n\n topBarText: getContrastRatio(alphaBlend(bgs.topBar, opacity.topBar, fgs.topBarText), fgs.topBarText),\n topBarLink: getContrastRatio(alphaBlend(bgs.topBar, opacity.topBar, fgs.topBarLink), fgs.topBarLink)\n }\n\n return Object.entries(ratios).reduce((acc, [k, v]) => { acc[k] = hints(v); return acc }, {})\n },\n previewRules () {\n if (!this.preview.rules) return ''\n return [\n ...Object.values(this.preview.rules),\n 'color: var(--text)',\n 'font-family: var(--interfaceFont, sans-serif)'\n ].join(';')\n },\n shadowsAvailable () {\n return Object.keys(this.previewTheme.shadows).sort()\n },\n currentShadowOverriden: {\n get () {\n return !!this.currentShadow\n },\n set (val) {\n if (val) {\n set(this.shadowsLocal, this.shadowSelected, this.currentShadowFallback.map(_ => Object.assign({}, _)))\n } else {\n del(this.shadowsLocal, this.shadowSelected)\n }\n }\n },\n currentShadowFallback () {\n return this.previewTheme.shadows[this.shadowSelected]\n },\n currentShadow: {\n get () {\n return this.shadowsLocal[this.shadowSelected]\n },\n set (v) {\n set(this.shadowsLocal, this.shadowSelected, v)\n }\n },\n themeValid () {\n return !this.shadowsInvalid && !this.colorsInvalid && !this.radiiInvalid\n },\n exportedTheme () {\n const saveEverything = (\n !this.keepFonts &&\n !this.keepShadows &&\n !this.keepOpacity &&\n !this.keepRoundness &&\n !this.keepColor\n )\n\n const theme = {}\n\n if (this.keepFonts || saveEverything) {\n theme.fonts = this.fontsLocal\n }\n if (this.keepShadows || saveEverything) {\n theme.shadows = this.shadowsLocal\n }\n if (this.keepOpacity || saveEverything) {\n theme.opacity = this.currentOpacity\n }\n if (this.keepColor || saveEverything) {\n theme.colors = this.currentColors\n }\n if (this.keepRoundness || saveEverything) {\n theme.radii = this.currentRadii\n }\n\n return {\n // To separate from other random JSON files and possible future theme formats\n _pleroma_theme_version: 2, theme\n }\n }\n },\n components: {\n ColorInput,\n OpacityInput,\n RangeInput,\n ContrastRatio,\n ShadowControl,\n FontControl,\n TabSwitcher,\n Preview,\n ExportImport,\n Checkbox\n },\n methods: {\n setCustomTheme () {\n this.$store.dispatch('setOption', {\n name: 'customTheme',\n value: {\n shadows: this.shadowsLocal,\n fonts: this.fontsLocal,\n opacity: this.currentOpacity,\n colors: this.currentColors,\n radii: this.currentRadii\n }\n })\n },\n onImport (parsed) {\n if (parsed._pleroma_theme_version === 1) {\n this.normalizeLocalState(parsed, 1)\n } else if (parsed._pleroma_theme_version === 2) {\n this.normalizeLocalState(parsed.theme, 2)\n }\n },\n importValidator (parsed) {\n const version = parsed._pleroma_theme_version\n return version >= 1 || version <= 2\n },\n clearAll () {\n const state = this.$store.getters.mergedConfig.customTheme\n const version = state.colors ? 2 : 'l1'\n this.normalizeLocalState(this.$store.getters.mergedConfig.customTheme, version)\n },\n\n // Clears all the extra stuff when loading V1 theme\n clearV1 () {\n Object.keys(this.$data)\n .filter(_ => _.endsWith('ColorLocal') || _.endsWith('OpacityLocal'))\n .filter(_ => !v1OnlyNames.includes(_))\n .forEach(key => {\n set(this.$data, key, undefined)\n })\n },\n\n clearRoundness () {\n Object.keys(this.$data)\n .filter(_ => _.endsWith('RadiusLocal'))\n .forEach(key => {\n set(this.$data, key, undefined)\n })\n },\n\n clearOpacity () {\n Object.keys(this.$data)\n .filter(_ => _.endsWith('OpacityLocal'))\n .forEach(key => {\n set(this.$data, key, undefined)\n })\n },\n\n clearShadows () {\n this.shadowsLocal = {}\n },\n\n clearFonts () {\n this.fontsLocal = {}\n },\n\n /**\n * This applies stored theme data onto form. Supports three versions of data:\n * v2 (version = 2) - newer version of themes.\n * v1 (version = 1) - older version of themes (import from file)\n * v1l (version = l1) - older version of theme (load from local storage)\n * v1 and v1l differ because of way themes were stored/exported.\n * @param {Object} input - input data\n * @param {Number} version - version of data. 0 means try to guess based on data. \"l1\" means v1, locastorage type\n */\n normalizeLocalState (input, version = 0) {\n const colors = input.colors || input\n const radii = input.radii || input\n const opacity = input.opacity\n const shadows = input.shadows || {}\n const fonts = input.fonts || {}\n\n if (version === 0) {\n if (input.version) version = input.version\n // Old v1 naming: fg is text, btn is foreground\n if (typeof colors.text === 'undefined' && typeof colors.fg !== 'undefined') {\n version = 1\n }\n // New v2 naming: text is text, fg is foreground\n if (typeof colors.text !== 'undefined' && typeof colors.fg !== 'undefined') {\n version = 2\n }\n }\n\n // Stuff that differs between V1 and V2\n if (version === 1) {\n this.fgColorLocal = rgb2hex(colors.btn)\n this.textColorLocal = rgb2hex(colors.fg)\n }\n\n if (!this.keepColor) {\n this.clearV1()\n const keys = new Set(version !== 1 ? Object.keys(colors) : [])\n if (version === 1 || version === 'l1') {\n keys\n .add('bg')\n .add('link')\n .add('cRed')\n .add('cBlue')\n .add('cGreen')\n .add('cOrange')\n }\n\n keys.forEach(key => {\n this[key + 'ColorLocal'] = rgb2hex(colors[key])\n })\n }\n\n if (!this.keepRoundness) {\n this.clearRoundness()\n Object.entries(radii).forEach(([k, v]) => {\n // 'Radius' is kept mostly for v1->v2 localstorage transition\n const key = k.endsWith('Radius') ? k.split('Radius')[0] : k\n this[key + 'RadiusLocal'] = v\n })\n }\n\n if (!this.keepShadows) {\n this.clearShadows()\n this.shadowsLocal = shadows\n this.shadowSelected = this.shadowsAvailable[0]\n }\n\n if (!this.keepFonts) {\n this.clearFonts()\n this.fontsLocal = fonts\n }\n\n if (opacity && !this.keepOpacity) {\n this.clearOpacity()\n Object.entries(opacity).forEach(([k, v]) => {\n if (typeof v === 'undefined' || v === null || Number.isNaN(v)) return\n this[k + 'OpacityLocal'] = v\n })\n }\n }\n },\n watch: {\n currentRadii () {\n try {\n this.previewRadii = generateRadii({ radii: this.currentRadii })\n this.radiiInvalid = false\n } catch (e) {\n this.radiiInvalid = true\n console.warn(e)\n }\n },\n shadowsLocal: {\n handler () {\n try {\n this.previewShadows = generateShadows({ shadows: this.shadowsLocal })\n this.shadowsInvalid = false\n } catch (e) {\n this.shadowsInvalid = true\n console.warn(e)\n }\n },\n deep: true\n },\n fontsLocal: {\n handler () {\n try {\n this.previewFonts = generateFonts({ fonts: this.fontsLocal })\n this.fontsInvalid = false\n } catch (e) {\n this.fontsInvalid = true\n console.warn(e)\n }\n },\n deep: true\n },\n currentColors () {\n try {\n this.previewColors = generateColors({\n opacity: this.currentOpacity,\n colors: this.currentColors\n })\n this.colorsInvalid = false\n } catch (e) {\n this.colorsInvalid = true\n console.warn(e)\n }\n },\n currentOpacity () {\n try {\n this.previewColors = generateColors({\n opacity: this.currentOpacity,\n colors: this.currentColors\n })\n } catch (e) {\n console.warn(e)\n }\n },\n selected () {\n if (this.selectedVersion === 1) {\n if (!this.keepRoundness) {\n this.clearRoundness()\n }\n\n if (!this.keepShadows) {\n this.clearShadows()\n }\n\n if (!this.keepOpacity) {\n this.clearOpacity()\n }\n\n if (!this.keepColor) {\n this.clearV1()\n\n this.bgColorLocal = this.selected[1]\n this.fgColorLocal = this.selected[2]\n this.textColorLocal = this.selected[3]\n this.linkColorLocal = this.selected[4]\n this.cRedColorLocal = this.selected[5]\n this.cGreenColorLocal = this.selected[6]\n this.cBlueColorLocal = this.selected[7]\n this.cOrangeColorLocal = this.selected[8]\n }\n } else if (this.selectedVersion >= 2) {\n this.normalizeLocalState(this.selected.theme, 2)\n }\n }\n }\n}\n","\n\n\n\n\n","\n\n\n","\n\n\n","import ColorInput from '../color_input/color_input.vue'\nimport OpacityInput from '../opacity_input/opacity_input.vue'\nimport { getCssShadow } from '../../services/style_setter/style_setter.js'\nimport { hex2rgb } from '../../services/color_convert/color_convert.js'\n\nexport default {\n // 'Value' and 'Fallback' can be undefined, but if they are\n // initially vue won't detect it when they become something else\n // therefore i'm using \"ready\" which should be passed as true when\n // data becomes available\n props: [\n 'value', 'fallback', 'ready'\n ],\n data () {\n return {\n selectedId: 0,\n // TODO there are some bugs regarding display of array (it's not getting updated when deleting for some reason)\n cValue: this.value || this.fallback || []\n }\n },\n components: {\n ColorInput,\n OpacityInput\n },\n methods: {\n add () {\n this.cValue.push(Object.assign({}, this.selected))\n this.selectedId = this.cValue.length - 1\n },\n del () {\n this.cValue.splice(this.selectedId, 1)\n this.selectedId = this.cValue.length === 0 ? undefined : this.selectedId - 1\n },\n moveUp () {\n const movable = this.cValue.splice(this.selectedId, 1)[0]\n this.cValue.splice(this.selectedId - 1, 0, movable)\n this.selectedId -= 1\n },\n moveDn () {\n const movable = this.cValue.splice(this.selectedId, 1)[0]\n this.cValue.splice(this.selectedId + 1, 0, movable)\n this.selectedId += 1\n }\n },\n beforeUpdate () {\n this.cValue = this.value || this.fallback\n },\n computed: {\n selected () {\n if (this.ready && this.cValue.length > 0) {\n return this.cValue[this.selectedId]\n } else {\n return {\n x: 0,\n y: 0,\n blur: 0,\n spread: 0,\n inset: false,\n color: '#000000',\n alpha: 1\n }\n }\n },\n moveUpValid () {\n return this.ready && this.selectedId > 0\n },\n moveDnValid () {\n return this.ready && this.selectedId < this.cValue.length - 1\n },\n present () {\n return this.ready &&\n typeof this.cValue[this.selectedId] !== 'undefined' &&\n !this.usingFallback\n },\n usingFallback () {\n return typeof this.value === 'undefined'\n },\n rgb () {\n return hex2rgb(this.selected.color)\n },\n style () {\n return this.ready ? {\n boxShadow: getCssShadow(this.cValue)\n } : {}\n }\n }\n}\n","import { set } from 'vue'\n\nexport default {\n props: [\n 'name', 'label', 'value', 'fallback', 'options', 'no-inherit'\n ],\n data () {\n return {\n lValue: this.value,\n availableOptions: [\n this.noInherit ? '' : 'inherit',\n 'custom',\n ...(this.options || []),\n 'serif',\n 'monospace',\n 'sans-serif'\n ].filter(_ => _)\n }\n },\n beforeUpdate () {\n this.lValue = this.value\n },\n computed: {\n present () {\n return typeof this.lValue !== 'undefined'\n },\n dValue () {\n return this.lValue || this.fallback || {}\n },\n family: {\n get () {\n return this.dValue.family\n },\n set (v) {\n set(this.lValue, 'family', v)\n this.$emit('input', this.lValue)\n }\n },\n isCustom () {\n return this.preset === 'custom'\n },\n preset: {\n get () {\n if (this.family === 'serif' ||\n this.family === 'sans-serif' ||\n this.family === 'monospace' ||\n this.family === 'inherit') {\n return this.family\n } else {\n return 'custom'\n }\n },\n set (v) {\n this.family = v === 'custom' ? '' : v\n }\n }\n }\n}\n","\n\n\n\n\n","\n\n\n\n\n","\n\n\n","import { validationMixin } from 'vuelidate'\nimport { required, sameAs } from 'vuelidate/lib/validators'\nimport { mapActions, mapState } from 'vuex'\n\nconst registration = {\n mixins: [validationMixin],\n data: () => ({\n user: {\n email: '',\n fullname: '',\n username: '',\n password: '',\n confirm: ''\n },\n captcha: {}\n }),\n validations: {\n user: {\n email: { required },\n username: { required },\n fullname: { required },\n password: { required },\n confirm: {\n required,\n sameAsPassword: sameAs('password')\n }\n }\n },\n created () {\n if ((!this.registrationOpen && !this.token) || this.signedIn) {\n this.$router.push({ name: 'root' })\n }\n\n this.setCaptcha()\n },\n computed: {\n token () { return this.$route.params.token },\n bioPlaceholder () {\n return this.$t('registration.bio_placeholder').replace(/\\s*\\n\\s*/g, ' \\n')\n },\n ...mapState({\n registrationOpen: (state) => state.instance.registrationOpen,\n signedIn: (state) => !!state.users.currentUser,\n isPending: (state) => state.users.signUpPending,\n serverValidationErrors: (state) => state.users.signUpErrors,\n termsOfService: (state) => state.instance.tos\n })\n },\n methods: {\n ...mapActions(['signUp', 'getCaptcha']),\n async submit () {\n this.user.nickname = this.user.username\n this.user.token = this.token\n\n this.user.captcha_solution = this.captcha.solution\n this.user.captcha_token = this.captcha.token\n this.user.captcha_answer_data = this.captcha.answer_data\n\n this.$v.$touch()\n\n if (!this.$v.$invalid) {\n try {\n await this.signUp(this.user)\n this.$router.push({ name: 'friends' })\n } catch (error) {\n console.warn('Registration failed: ' + error)\n }\n }\n },\n setCaptcha () {\n this.getCaptcha().then(cpt => { this.captcha = cpt })\n }\n }\n}\n\nexport default registration\n","import { mapState } from 'vuex'\nimport passwordResetApi from '../../services/new_api/password_reset.js'\n\nconst passwordReset = {\n data: () => ({\n user: {\n email: ''\n },\n isPending: false,\n success: false,\n throttled: false,\n error: null\n }),\n computed: {\n ...mapState({\n signedIn: (state) => !!state.users.currentUser,\n instance: state => state.instance\n }),\n mailerEnabled () {\n return this.instance.mailerEnabled\n }\n },\n created () {\n if (this.signedIn) {\n this.$router.push({ name: 'root' })\n }\n },\n props: {\n passwordResetRequested: {\n default: false,\n type: Boolean\n }\n },\n methods: {\n dismissError () {\n this.error = null\n },\n submit () {\n this.isPending = true\n const email = this.user.email\n const instance = this.instance.server\n\n passwordResetApi({ instance, email }).then(({ status }) => {\n this.isPending = false\n this.user.email = ''\n\n if (status === 204) {\n this.success = true\n this.error = null\n } else if (status === 404 || status === 400) {\n this.error = this.$t('password_reset.not_found')\n this.$nextTick(() => {\n this.$refs.email.focus()\n })\n } else if (status === 429) {\n this.throttled = true\n this.error = this.$t('password_reset.too_many_requests')\n }\n }).catch(() => {\n this.isPending = false\n this.user.email = ''\n this.error = this.$t('general.generic_error')\n })\n }\n }\n}\n\nexport default passwordReset\n","import unescape from 'lodash/unescape'\nimport get from 'lodash/get'\nimport map from 'lodash/map'\nimport reject from 'lodash/reject'\nimport TabSwitcher from '../tab_switcher/tab_switcher.js'\nimport ImageCropper from '../image_cropper/image_cropper.vue'\nimport StyleSwitcher from '../style_switcher/style_switcher.vue'\nimport ScopeSelector from '../scope_selector/scope_selector.vue'\nimport fileSizeFormatService from '../../services/file_size_format/file_size_format.js'\nimport BlockCard from '../block_card/block_card.vue'\nimport MuteCard from '../mute_card/mute_card.vue'\nimport SelectableList from '../selectable_list/selectable_list.vue'\nimport ProgressButton from '../progress_button/progress_button.vue'\nimport EmojiInput from '../emoji_input/emoji_input.vue'\nimport suggestor from '../emoji_input/suggestor.js'\nimport Autosuggest from '../autosuggest/autosuggest.vue'\nimport Importer from '../importer/importer.vue'\nimport Exporter from '../exporter/exporter.vue'\nimport withSubscription from '../../hocs/with_subscription/with_subscription'\nimport Checkbox from '../checkbox/checkbox.vue'\nimport Mfa from './mfa.vue'\n\nconst BlockList = withSubscription({\n fetch: (props, $store) => $store.dispatch('fetchBlocks'),\n select: (props, $store) => get($store.state.users.currentUser, 'blockIds', []),\n childPropName: 'items'\n})(SelectableList)\n\nconst MuteList = withSubscription({\n fetch: (props, $store) => $store.dispatch('fetchMutes'),\n select: (props, $store) => get($store.state.users.currentUser, 'muteIds', []),\n childPropName: 'items'\n})(SelectableList)\n\nconst UserSettings = {\n data () {\n return {\n newEmail: '',\n newName: this.$store.state.users.currentUser.name,\n newBio: unescape(this.$store.state.users.currentUser.description),\n newLocked: this.$store.state.users.currentUser.locked,\n newNoRichText: this.$store.state.users.currentUser.no_rich_text,\n newDefaultScope: this.$store.state.users.currentUser.default_scope,\n hideFollows: this.$store.state.users.currentUser.hide_follows,\n hideFollowers: this.$store.state.users.currentUser.hide_followers,\n hideFollowsCount: this.$store.state.users.currentUser.hide_follows_count,\n hideFollowersCount: this.$store.state.users.currentUser.hide_followers_count,\n showRole: this.$store.state.users.currentUser.show_role,\n role: this.$store.state.users.currentUser.role,\n discoverable: this.$store.state.users.currentUser.discoverable,\n pickAvatarBtnVisible: true,\n bannerUploading: false,\n backgroundUploading: false,\n banner: null,\n bannerPreview: null,\n background: null,\n backgroundPreview: null,\n bannerUploadError: null,\n backgroundUploadError: null,\n changeEmailError: false,\n changeEmailPassword: '',\n changedEmail: false,\n deletingAccount: false,\n deleteAccountConfirmPasswordInput: '',\n deleteAccountError: false,\n changePasswordInputs: [ '', '', '' ],\n changedPassword: false,\n changePasswordError: false,\n activeTab: 'profile',\n notificationSettings: this.$store.state.users.currentUser.notification_settings\n }\n },\n created () {\n this.$store.dispatch('fetchTokens')\n },\n components: {\n StyleSwitcher,\n ScopeSelector,\n TabSwitcher,\n ImageCropper,\n BlockList,\n MuteList,\n EmojiInput,\n Autosuggest,\n BlockCard,\n MuteCard,\n ProgressButton,\n Importer,\n Exporter,\n Mfa,\n Checkbox\n },\n computed: {\n user () {\n return this.$store.state.users.currentUser\n },\n emojiUserSuggestor () {\n return suggestor({\n emoji: [\n ...this.$store.state.instance.emoji,\n ...this.$store.state.instance.customEmoji\n ],\n users: this.$store.state.users.users,\n updateUsersList: (input) => this.$store.dispatch('searchUsers', input)\n })\n },\n emojiSuggestor () {\n return suggestor({ emoji: [\n ...this.$store.state.instance.emoji,\n ...this.$store.state.instance.customEmoji\n ] })\n },\n pleromaBackend () {\n return this.$store.state.instance.pleromaBackend\n },\n minimalScopesMode () {\n return this.$store.state.instance.minimalScopesMode\n },\n vis () {\n return {\n public: { selected: this.newDefaultScope === 'public' },\n unlisted: { selected: this.newDefaultScope === 'unlisted' },\n private: { selected: this.newDefaultScope === 'private' },\n direct: { selected: this.newDefaultScope === 'direct' }\n }\n },\n currentSaveStateNotice () {\n return this.$store.state.interface.settings.currentSaveStateNotice\n },\n oauthTokens () {\n return this.$store.state.oauthTokens.tokens.map(oauthToken => {\n return {\n id: oauthToken.id,\n appName: oauthToken.app_name,\n validUntil: new Date(oauthToken.valid_until).toLocaleDateString()\n }\n })\n }\n },\n methods: {\n updateProfile () {\n this.$store.state.api.backendInteractor\n .updateProfile({\n params: {\n note: this.newBio,\n locked: this.newLocked,\n // Backend notation.\n /* eslint-disable camelcase */\n display_name: this.newName,\n default_scope: this.newDefaultScope,\n no_rich_text: this.newNoRichText,\n hide_follows: this.hideFollows,\n hide_followers: this.hideFollowers,\n discoverable: this.discoverable,\n hide_follows_count: this.hideFollowsCount,\n hide_followers_count: this.hideFollowersCount,\n show_role: this.showRole\n /* eslint-enable camelcase */\n } }).then((user) => {\n this.$store.commit('addNewUsers', [user])\n this.$store.commit('setCurrentUser', user)\n })\n },\n updateNotificationSettings () {\n this.$store.state.api.backendInteractor\n .updateNotificationSettings({ settings: this.notificationSettings })\n },\n changeVis (visibility) {\n this.newDefaultScope = visibility\n },\n uploadFile (slot, e) {\n const file = e.target.files[0]\n if (!file) { return }\n if (file.size > this.$store.state.instance[slot + 'limit']) {\n const filesize = fileSizeFormatService.fileSizeFormat(file.size)\n const allowedsize = fileSizeFormatService.fileSizeFormat(this.$store.state.instance[slot + 'limit'])\n this[slot + 'UploadError'] = this.$t('upload.error.base') + ' ' + this.$t('upload.error.file_too_big', { filesize: filesize.num, filesizeunit: filesize.unit, allowedsize: allowedsize.num, allowedsizeunit: allowedsize.unit })\n return\n }\n // eslint-disable-next-line no-undef\n const reader = new FileReader()\n reader.onload = ({ target }) => {\n const img = target.result\n this[slot + 'Preview'] = img\n this[slot] = file\n }\n reader.readAsDataURL(file)\n },\n submitAvatar (cropper, file) {\n const that = this\n return new Promise((resolve, reject) => {\n function updateAvatar (avatar) {\n that.$store.state.api.backendInteractor.updateAvatar({ avatar })\n .then((user) => {\n that.$store.commit('addNewUsers', [user])\n that.$store.commit('setCurrentUser', user)\n resolve()\n })\n .catch((err) => {\n reject(new Error(that.$t('upload.error.base') + ' ' + err.message))\n })\n }\n\n if (cropper) {\n cropper.getCroppedCanvas().toBlob(updateAvatar, file.type)\n } else {\n updateAvatar(file)\n }\n })\n },\n clearUploadError (slot) {\n this[slot + 'UploadError'] = null\n },\n submitBanner () {\n if (!this.bannerPreview) { return }\n\n this.bannerUploading = true\n this.$store.state.api.backendInteractor.updateBanner({ banner: this.banner })\n .then((user) => {\n this.$store.commit('addNewUsers', [user])\n this.$store.commit('setCurrentUser', user)\n this.bannerPreview = null\n })\n .catch((err) => {\n this.bannerUploadError = this.$t('upload.error.base') + ' ' + err.message\n })\n .then(() => { this.bannerUploading = false })\n },\n submitBg () {\n if (!this.backgroundPreview) { return }\n let background = this.background\n this.backgroundUploading = true\n this.$store.state.api.backendInteractor.updateBg({ background }).then((data) => {\n if (!data.error) {\n this.$store.commit('addNewUsers', [data])\n this.$store.commit('setCurrentUser', data)\n this.backgroundPreview = null\n } else {\n this.backgroundUploadError = this.$t('upload.error.base') + data.error\n }\n this.backgroundUploading = false\n })\n },\n importFollows (file) {\n return this.$store.state.api.backendInteractor.importFollows(file)\n .then((status) => {\n if (!status) {\n throw new Error('failed')\n }\n })\n },\n importBlocks (file) {\n return this.$store.state.api.backendInteractor.importBlocks(file)\n .then((status) => {\n if (!status) {\n throw new Error('failed')\n }\n })\n },\n generateExportableUsersContent (users) {\n // Get addresses\n return users.map((user) => {\n // check is it's a local user\n if (user && user.is_local) {\n // append the instance address\n // eslint-disable-next-line no-undef\n return user.screen_name + '@' + location.hostname\n }\n return user.screen_name\n }).join('\\n')\n },\n getFollowsContent () {\n return this.$store.state.api.backendInteractor.exportFriends({ id: this.$store.state.users.currentUser.id })\n .then(this.generateExportableUsersContent)\n },\n getBlocksContent () {\n return this.$store.state.api.backendInteractor.fetchBlocks()\n .then(this.generateExportableUsersContent)\n },\n confirmDelete () {\n this.deletingAccount = true\n },\n deleteAccount () {\n this.$store.state.api.backendInteractor.deleteAccount({ password: this.deleteAccountConfirmPasswordInput })\n .then((res) => {\n if (res.status === 'success') {\n this.$store.dispatch('logout')\n this.$router.push({ name: 'root' })\n } else {\n this.deleteAccountError = res.error\n }\n })\n },\n changePassword () {\n const params = {\n password: this.changePasswordInputs[0],\n newPassword: this.changePasswordInputs[1],\n newPasswordConfirmation: this.changePasswordInputs[2]\n }\n this.$store.state.api.backendInteractor.changePassword(params)\n .then((res) => {\n if (res.status === 'success') {\n this.changedPassword = true\n this.changePasswordError = false\n this.logout()\n } else {\n this.changedPassword = false\n this.changePasswordError = res.error\n }\n })\n },\n changeEmail () {\n const params = {\n email: this.newEmail,\n password: this.changeEmailPassword\n }\n this.$store.state.api.backendInteractor.changeEmail(params)\n .then((res) => {\n if (res.status === 'success') {\n this.changedEmail = true\n this.changeEmailError = false\n } else {\n this.changedEmail = false\n this.changeEmailError = res.error\n }\n })\n },\n activateTab (tabName) {\n this.activeTab = tabName\n },\n logout () {\n this.$store.dispatch('logout')\n this.$router.replace('/')\n },\n revokeToken (id) {\n if (window.confirm(`${this.$i18n.t('settings.revoke_token')}?`)) {\n this.$store.dispatch('revokeToken', id)\n }\n },\n filterUnblockedUsers (userIds) {\n return reject(userIds, (userId) => {\n const user = this.$store.getters.findUser(userId)\n return !user || user.statusnet_blocking || user.id === this.$store.state.users.currentUser.id\n })\n },\n filterUnMutedUsers (userIds) {\n return reject(userIds, (userId) => {\n const user = this.$store.getters.findUser(userId)\n return !user || user.muted || user.id === this.$store.state.users.currentUser.id\n })\n },\n queryUserIds (query) {\n return this.$store.dispatch('searchUsers', query)\n .then((users) => map(users, 'id'))\n },\n blockUsers (ids) {\n return this.$store.dispatch('blockUsers', ids)\n },\n unblockUsers (ids) {\n return this.$store.dispatch('unblockUsers', ids)\n },\n muteUsers (ids) {\n return this.$store.dispatch('muteUsers', ids)\n },\n unmuteUsers (ids) {\n return this.$store.dispatch('unmuteUsers', ids)\n },\n identity (value) {\n return value\n }\n }\n}\n\nexport default UserSettings\n","import Cropper from 'cropperjs'\nimport 'cropperjs/dist/cropper.css'\n\nconst ImageCropper = {\n props: {\n trigger: {\n type: [String, window.Element],\n required: true\n },\n submitHandler: {\n type: Function,\n required: true\n },\n cropperOptions: {\n type: Object,\n default () {\n return {\n aspectRatio: 1,\n autoCropArea: 1,\n viewMode: 1,\n movable: false,\n zoomable: false,\n guides: false\n }\n }\n },\n mimes: {\n type: String,\n default: 'image/png, image/gif, image/jpeg, image/bmp, image/x-icon'\n },\n saveButtonLabel: {\n type: String\n },\n saveWithoutCroppingButtonlabel: {\n type: String\n },\n cancelButtonLabel: {\n type: String\n }\n },\n data () {\n return {\n cropper: undefined,\n dataUrl: undefined,\n filename: undefined,\n submitting: false,\n submitError: null\n }\n },\n computed: {\n saveText () {\n return this.saveButtonLabel || this.$t('image_cropper.save')\n },\n saveWithoutCroppingText () {\n return this.saveWithoutCroppingButtonlabel || this.$t('image_cropper.save_without_cropping')\n },\n cancelText () {\n return this.cancelButtonLabel || this.$t('image_cropper.cancel')\n },\n submitErrorMsg () {\n return this.submitError && this.submitError instanceof Error ? this.submitError.toString() : this.submitError\n }\n },\n methods: {\n destroy () {\n if (this.cropper) {\n this.cropper.destroy()\n }\n this.$refs.input.value = ''\n this.dataUrl = undefined\n this.$emit('close')\n },\n submit (cropping = true) {\n this.submitting = true\n this.avatarUploadError = null\n this.submitHandler(cropping && this.cropper, this.file)\n .then(() => this.destroy())\n .catch((err) => {\n this.submitError = err\n })\n .finally(() => {\n this.submitting = false\n })\n },\n pickImage () {\n this.$refs.input.click()\n },\n createCropper () {\n this.cropper = new Cropper(this.$refs.img, this.cropperOptions)\n },\n getTriggerDOM () {\n return typeof this.trigger === 'object' ? this.trigger : document.querySelector(this.trigger)\n },\n readFile () {\n const fileInput = this.$refs.input\n if (fileInput.files != null && fileInput.files[0] != null) {\n this.file = fileInput.files[0]\n let reader = new window.FileReader()\n reader.onload = (e) => {\n this.dataUrl = e.target.result\n this.$emit('open')\n }\n reader.readAsDataURL(this.file)\n this.$emit('changed', this.file, reader)\n }\n },\n clearError () {\n this.submitError = null\n }\n },\n mounted () {\n // listen for click event on trigger\n const trigger = this.getTriggerDOM()\n if (!trigger) {\n this.$emit('error', 'No image make trigger found.', 'user')\n } else {\n trigger.addEventListener('click', this.pickImage)\n }\n // listen for input file changes\n const fileInput = this.$refs.input\n fileInput.addEventListener('change', this.readFile)\n },\n beforeDestroy: function () {\n // remove the event listeners\n const trigger = this.getTriggerDOM()\n if (trigger) {\n trigger.removeEventListener('click', this.pickImage)\n }\n const fileInput = this.$refs.input\n fileInput.removeEventListener('change', this.readFile)\n }\n}\n\nexport default ImageCropper\n","import BasicUserCard from '../basic_user_card/basic_user_card.vue'\n\nconst BlockCard = {\n props: ['userId'],\n data () {\n return {\n progress: false\n }\n },\n computed: {\n user () {\n return this.$store.getters.findUser(this.userId)\n },\n blocked () {\n return this.user.statusnet_blocking\n }\n },\n components: {\n BasicUserCard\n },\n methods: {\n unblockUser () {\n this.progress = true\n this.$store.dispatch('unblockUser', this.user.id).then(() => {\n this.progress = false\n })\n },\n blockUser () {\n this.progress = true\n this.$store.dispatch('blockUser', this.user.id).then(() => {\n this.progress = false\n })\n }\n }\n}\n\nexport default BlockCard\n","import BasicUserCard from '../basic_user_card/basic_user_card.vue'\n\nconst MuteCard = {\n props: ['userId'],\n data () {\n return {\n progress: false\n }\n },\n computed: {\n user () {\n return this.$store.getters.findUser(this.userId)\n },\n muted () {\n return this.user.muted\n }\n },\n components: {\n BasicUserCard\n },\n methods: {\n unmuteUser () {\n this.progress = true\n this.$store.dispatch('unmuteUser', this.user.id).then(() => {\n this.progress = false\n })\n },\n muteUser () {\n this.progress = true\n this.$store.dispatch('muteUser', this.user.id).then(() => {\n this.progress = false\n })\n }\n }\n}\n\nexport default MuteCard\n","import List from '../list/list.vue'\nimport Checkbox from '../checkbox/checkbox.vue'\n\nconst SelectableList = {\n components: {\n List,\n Checkbox\n },\n props: {\n items: {\n type: Array,\n default: () => []\n },\n getKey: {\n type: Function,\n default: item => item.id\n }\n },\n data () {\n return {\n selected: []\n }\n },\n computed: {\n allKeys () {\n return this.items.map(this.getKey)\n },\n filteredSelected () {\n return this.allKeys.filter(key => this.selected.indexOf(key) !== -1)\n },\n allSelected () {\n return this.filteredSelected.length === this.items.length\n },\n noneSelected () {\n return this.filteredSelected.length === 0\n },\n someSelected () {\n return !this.allSelected && !this.noneSelected\n }\n },\n methods: {\n isSelected (item) {\n return this.filteredSelected.indexOf(this.getKey(item)) !== -1\n },\n toggle (checked, item) {\n const key = this.getKey(item)\n const oldChecked = this.isSelected(key)\n if (checked !== oldChecked) {\n if (checked) {\n this.selected.push(key)\n } else {\n this.selected.splice(this.selected.indexOf(key), 1)\n }\n }\n },\n toggleAll (value) {\n if (value) {\n this.selected = this.allKeys.slice(0)\n } else {\n this.selected = []\n }\n }\n }\n}\n\nexport default SelectableList\n","const debounceMilliseconds = 500\n\nexport default {\n props: {\n query: { // function to query results and return a promise\n type: Function,\n required: true\n },\n filter: { // function to filter results in real time\n type: Function\n },\n placeholder: {\n type: String,\n default: 'Search...'\n }\n },\n data () {\n return {\n term: '',\n timeout: null,\n results: [],\n resultsVisible: false\n }\n },\n computed: {\n filtered () {\n return this.filter ? this.filter(this.results) : this.results\n }\n },\n watch: {\n term (val) {\n this.fetchResults(val)\n }\n },\n methods: {\n fetchResults (term) {\n clearTimeout(this.timeout)\n this.timeout = setTimeout(() => {\n this.results = []\n if (term) {\n this.query(term).then((results) => { this.results = results })\n }\n }, debounceMilliseconds)\n },\n onInputClick () {\n this.resultsVisible = true\n },\n onClickOutside () {\n this.resultsVisible = false\n }\n }\n}\n","const Importer = {\n props: {\n submitHandler: {\n type: Function,\n required: true\n },\n submitButtonLabel: {\n type: String,\n default () {\n return this.$t('importer.submit')\n }\n },\n successMessage: {\n type: String,\n default () {\n return this.$t('importer.success')\n }\n },\n errorMessage: {\n type: String,\n default () {\n return this.$t('importer.error')\n }\n }\n },\n data () {\n return {\n file: null,\n error: false,\n success: false,\n submitting: false\n }\n },\n methods: {\n change () {\n this.file = this.$refs.input.files[0]\n },\n submit () {\n this.dismiss()\n this.submitting = true\n this.submitHandler(this.file)\n .then(() => { this.success = true })\n .catch(() => { this.error = true })\n .finally(() => { this.submitting = false })\n },\n dismiss () {\n this.success = false\n this.error = false\n }\n }\n}\n\nexport default Importer\n","const Exporter = {\n props: {\n getContent: {\n type: Function,\n required: true\n },\n filename: {\n type: String,\n default: 'export.csv'\n },\n exportButtonLabel: {\n type: String,\n default () {\n return this.$t('exporter.export')\n }\n },\n processingMessage: {\n type: String,\n default () {\n return this.$t('exporter.processing')\n }\n }\n },\n data () {\n return {\n processing: false\n }\n },\n methods: {\n process () {\n this.processing = true\n this.getContent()\n .then((content) => {\n const fileToDownload = document.createElement('a')\n fileToDownload.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(content))\n fileToDownload.setAttribute('download', this.filename)\n fileToDownload.style.display = 'none'\n document.body.appendChild(fileToDownload)\n fileToDownload.click()\n document.body.removeChild(fileToDownload)\n // Add delay before hiding processing state since browser takes some time to handle file download\n setTimeout(() => { this.processing = false }, 2000)\n })\n }\n }\n}\n\nexport default Exporter\n","import RecoveryCodes from './mfa_backup_codes.vue'\nimport TOTP from './mfa_totp.vue'\nimport Confirm from './confirm.vue'\nimport VueQrcode from '@chenfengyuan/vue-qrcode'\nimport { mapState } from 'vuex'\n\nconst Mfa = {\n data: () => ({\n settings: { // current settings of MFA\n available: false,\n enabled: false,\n totp: false\n },\n setupState: { // setup mfa\n state: '', // state of setup. '' -> 'getBackupCodes' -> 'setupOTP' -> 'complete'\n setupOTPState: '' // state of setup otp. '' -> 'prepare' -> 'confirm' -> 'complete'\n },\n backupCodes: {\n getNewCodes: false,\n inProgress: false, // progress of fetch codes\n codes: []\n },\n otpSettings: { // pre-setup setting of OTP. secret key, qrcode url.\n provisioning_uri: '',\n key: ''\n },\n currentPassword: null,\n otpConfirmToken: null,\n error: null,\n readyInit: false\n }),\n components: {\n 'recovery-codes': RecoveryCodes,\n 'totp-item': TOTP,\n 'qrcode': VueQrcode,\n 'confirm': Confirm\n },\n computed: {\n canSetupOTP () {\n return (\n (this.setupInProgress && this.backupCodesPrepared) ||\n this.settings.enabled\n ) && !this.settings.totp && !this.setupOTPInProgress\n },\n setupInProgress () {\n return this.setupState.state !== '' && this.setupState.state !== 'complete'\n },\n setupOTPInProgress () {\n return this.setupState.state === 'setupOTP' && !this.completedOTP\n },\n prepareOTP () {\n return this.setupState.setupOTPState === 'prepare'\n },\n confirmOTP () {\n return this.setupState.setupOTPState === 'confirm'\n },\n completedOTP () {\n return this.setupState.setupOTPState === 'completed'\n },\n backupCodesPrepared () {\n return !this.backupCodes.inProgress && this.backupCodes.codes.length > 0\n },\n confirmNewBackupCodes () {\n return this.backupCodes.getNewCodes\n },\n ...mapState({\n backendInteractor: (state) => state.api.backendInteractor\n })\n },\n\n methods: {\n activateOTP () {\n if (!this.settings.enabled) {\n this.setupState.state = 'getBackupcodes'\n this.fetchBackupCodes()\n }\n },\n fetchBackupCodes () {\n this.backupCodes.inProgress = true\n this.backupCodes.codes = []\n\n return this.backendInteractor.generateMfaBackupCodes()\n .then((res) => {\n this.backupCodes.codes = res.codes\n this.backupCodes.inProgress = false\n })\n },\n getBackupCodes () { // get a new backup codes\n this.backupCodes.getNewCodes = true\n },\n confirmBackupCodes () { // confirm getting new backup codes\n this.fetchBackupCodes().then((res) => {\n this.backupCodes.getNewCodes = false\n })\n },\n cancelBackupCodes () { // cancel confirm form of new backup codes\n this.backupCodes.getNewCodes = false\n },\n\n // Setup OTP\n setupOTP () { // prepare setup OTP\n this.setupState.state = 'setupOTP'\n this.setupState.setupOTPState = 'prepare'\n this.backendInteractor.mfaSetupOTP()\n .then((res) => {\n this.otpSettings = res\n this.setupState.setupOTPState = 'confirm'\n })\n },\n doConfirmOTP () { // handler confirm enable OTP\n this.error = null\n this.backendInteractor.mfaConfirmOTP({\n token: this.otpConfirmToken,\n password: this.currentPassword\n })\n .then((res) => {\n if (res.error) {\n this.error = res.error\n return\n }\n this.completeSetup()\n })\n },\n\n completeSetup () {\n this.setupState.setupOTPState = 'complete'\n this.setupState.state = 'complete'\n this.currentPassword = null\n this.error = null\n this.fetchSettings()\n },\n cancelSetup () { // cancel setup\n this.setupState.setupOTPState = ''\n this.setupState.state = ''\n this.currentPassword = null\n this.error = null\n },\n // end Setup OTP\n\n // fetch settings from server\n async fetchSettings () {\n let result = await this.backendInteractor.fetchSettingsMFA()\n if (result.error) return\n this.settings = result.settings\n this.settings.available = true\n return result\n }\n },\n mounted () {\n this.fetchSettings().then(() => {\n this.readyInit = true\n })\n }\n}\nexport default Mfa\n","export default {\n props: {\n backupCodes: {\n type: Object,\n default: () => ({\n inProgress: false,\n codes: []\n })\n }\n },\n data: () => ({}),\n computed: {\n inProgress () { return this.backupCodes.inProgress },\n ready () { return this.backupCodes.codes.length > 0 },\n displayTitle () { return this.inProgress || this.ready }\n }\n}\n","import Confirm from './confirm.vue'\nimport { mapState } from 'vuex'\n\nexport default {\n props: ['settings'],\n data: () => ({\n error: false,\n currentPassword: '',\n deactivate: false,\n inProgress: false // progress peform request to disable otp method\n }),\n components: {\n 'confirm': Confirm\n },\n computed: {\n isActivated () {\n return this.settings.totp\n },\n ...mapState({\n backendInteractor: (state) => state.api.backendInteractor\n })\n },\n methods: {\n doActivate () {\n this.$emit('activate')\n },\n cancelDeactivate () { this.deactivate = false },\n doDeactivate () {\n this.error = null\n this.deactivate = true\n },\n confirmDeactivate () { // confirm deactivate TOTP method\n this.error = null\n this.inProgress = true\n this.backendInteractor.mfaDisableOTP({\n password: this.currentPassword\n })\n .then((res) => {\n this.inProgress = false\n if (res.error) {\n this.error = res.error\n return\n }\n this.deactivate = false\n this.$emit('deactivate')\n })\n }\n }\n}\n","const Confirm = {\n props: ['disabled'],\n data: () => ({}),\n methods: {\n confirm () { this.$emit('confirm') },\n cancel () { this.$emit('cancel') }\n }\n}\nexport default Confirm\n","import FollowRequestCard from '../follow_request_card/follow_request_card.vue'\n\nconst FollowRequests = {\n components: {\n FollowRequestCard\n },\n computed: {\n requests () {\n return this.$store.state.api.followRequests\n }\n }\n}\n\nexport default FollowRequests\n","import BasicUserCard from '../basic_user_card/basic_user_card.vue'\n\nconst FollowRequestCard = {\n props: ['user'],\n components: {\n BasicUserCard\n },\n methods: {\n approveUser () {\n this.$store.state.api.backendInteractor.approveUser(this.user.id)\n this.$store.dispatch('removeFollowRequest', this.user)\n },\n denyUser () {\n this.$store.state.api.backendInteractor.denyUser(this.user.id)\n this.$store.dispatch('removeFollowRequest', this.user)\n }\n }\n}\n\nexport default FollowRequestCard\n","import oauth from '../../services/new_api/oauth.js'\n\nconst oac = {\n props: ['code'],\n mounted () {\n if (this.code) {\n const { clientId, clientSecret } = this.$store.state.oauth\n\n oauth.getToken({\n clientId,\n clientSecret,\n instance: this.$store.state.instance.server,\n code: this.code\n }).then((result) => {\n this.$store.commit('setToken', result.access_token)\n this.$store.dispatch('loginUser', result.access_token)\n this.$router.push({ name: 'friends' })\n })\n }\n }\n}\n\nexport default oac\n","import { mapState, mapGetters, mapActions, mapMutations } from 'vuex'\nimport oauthApi from '../../services/new_api/oauth.js'\n\nconst LoginForm = {\n data: () => ({\n user: {},\n error: false\n }),\n computed: {\n isPasswordAuth () { return this.requiredPassword },\n isTokenAuth () { return this.requiredToken },\n ...mapState({\n registrationOpen: state => state.instance.registrationOpen,\n instance: state => state.instance,\n loggingIn: state => state.users.loggingIn,\n oauth: state => state.oauth\n }),\n ...mapGetters(\n 'authFlow', ['requiredPassword', 'requiredToken', 'requiredMFA']\n )\n },\n methods: {\n ...mapMutations('authFlow', ['requireMFA']),\n ...mapActions({ login: 'authFlow/login' }),\n submit () {\n this.isTokenAuth ? this.submitToken() : this.submitPassword()\n },\n submitToken () {\n const { clientId, clientSecret } = this.oauth\n const data = {\n clientId,\n clientSecret,\n instance: this.instance.server,\n commit: this.$store.commit\n }\n\n oauthApi.getOrCreateApp(data)\n .then((app) => { oauthApi.login({ ...app, ...data }) })\n },\n submitPassword () {\n const { clientId } = this.oauth\n const data = {\n clientId,\n oauth: this.oauth,\n instance: this.instance.server,\n commit: this.$store.commit\n }\n this.error = false\n\n oauthApi.getOrCreateApp(data).then((app) => {\n oauthApi.getTokenWithCredentials(\n {\n ...app,\n instance: data.instance,\n username: this.user.username,\n password: this.user.password\n }\n ).then((result) => {\n if (result.error) {\n if (result.error === 'mfa_required') {\n this.requireMFA({ app: app, settings: result })\n } else if (result.identifier === 'password_reset_required') {\n this.$router.push({ name: 'password-reset', params: { passwordResetRequested: true } })\n } else {\n this.error = result.error\n this.focusOnPasswordInput()\n }\n return\n }\n this.login(result).then(() => {\n this.$router.push({ name: 'friends' })\n })\n })\n })\n },\n clearError () { this.error = false },\n focusOnPasswordInput () {\n let passwordInput = this.$refs.passwordInput\n passwordInput.focus()\n passwordInput.setSelectionRange(0, passwordInput.value.length)\n }\n }\n}\n\nexport default LoginForm\n","import mfaApi from '../../services/new_api/mfa.js'\nimport { mapState, mapGetters, mapActions, mapMutations } from 'vuex'\n\nexport default {\n data: () => ({\n code: null,\n error: false\n }),\n computed: {\n ...mapGetters({\n authApp: 'authFlow/app',\n authSettings: 'authFlow/settings'\n }),\n ...mapState({ instance: 'instance' })\n },\n methods: {\n ...mapMutations('authFlow', ['requireTOTP', 'abortMFA']),\n ...mapActions({ login: 'authFlow/login' }),\n clearError () { this.error = false },\n submit () {\n const data = {\n app: this.authApp,\n instance: this.instance.server,\n mfaToken: this.authSettings.mfa_token,\n code: this.code\n }\n\n mfaApi.verifyRecoveryCode(data).then((result) => {\n if (result.error) {\n this.error = result.error\n this.code = null\n return\n }\n\n this.login(result).then(() => {\n this.$router.push({ name: 'friends' })\n })\n })\n }\n }\n}\n","import mfaApi from '../../services/new_api/mfa.js'\nimport { mapState, mapGetters, mapActions, mapMutations } from 'vuex'\nexport default {\n data: () => ({\n code: null,\n error: false\n }),\n computed: {\n ...mapGetters({\n authApp: 'authFlow/app',\n authSettings: 'authFlow/settings'\n }),\n ...mapState({ instance: 'instance' })\n },\n methods: {\n ...mapMutations('authFlow', ['requireRecovery', 'abortMFA']),\n ...mapActions({ login: 'authFlow/login' }),\n clearError () { this.error = false },\n submit () {\n const data = {\n app: this.authApp,\n instance: this.instance.server,\n mfaToken: this.authSettings.mfa_token,\n code: this.code\n }\n\n mfaApi.verifyOTPCode(data).then((result) => {\n if (result.error) {\n this.error = result.error\n this.code = null\n return\n }\n\n this.login(result).then(() => {\n this.$router.push({ name: 'friends' })\n })\n })\n }\n }\n}\n","import generateProfileLink from 'src/services/user_profile_link_generator/user_profile_link_generator'\n\nconst chatPanel = {\n props: [ 'floating' ],\n data () {\n return {\n currentMessage: '',\n channel: null,\n collapsed: true\n }\n },\n computed: {\n messages () {\n return this.$store.state.chat.messages\n }\n },\n methods: {\n submit (message) {\n this.$store.state.chat.channel.push('new_msg', { text: message }, 10000)\n this.currentMessage = ''\n },\n togglePanel () {\n this.collapsed = !this.collapsed\n },\n userProfileLink (user) {\n return generateProfileLink(user.id, user.username, this.$store.state.instance.restrictedNicknames)\n }\n }\n}\n\nexport default chatPanel\n","import apiService from '../../services/api/api.service.js'\nimport FollowCard from '../follow_card/follow_card.vue'\n\nconst WhoToFollow = {\n components: {\n FollowCard\n },\n data () {\n return {\n users: []\n }\n },\n mounted () {\n this.getWhoToFollow()\n },\n methods: {\n showWhoToFollow (reply) {\n reply.forEach((i, index) => {\n this.$store.state.api.backendInteractor.fetchUser({ id: i.acct })\n .then((externalUser) => {\n if (!externalUser.error) {\n this.$store.commit('addNewUsers', [externalUser])\n this.users.push(externalUser)\n }\n })\n })\n },\n getWhoToFollow () {\n const credentials = this.$store.state.users.currentUser.credentials\n if (credentials) {\n apiService.suggestions({ credentials: credentials })\n .then((reply) => {\n this.showWhoToFollow(reply)\n })\n }\n }\n }\n}\n\nexport default WhoToFollow\n","import InstanceSpecificPanel from '../instance_specific_panel/instance_specific_panel.vue'\nimport FeaturesPanel from '../features_panel/features_panel.vue'\nimport TermsOfServicePanel from '../terms_of_service_panel/terms_of_service_panel.vue'\n\nconst About = {\n components: {\n InstanceSpecificPanel,\n FeaturesPanel,\n TermsOfServicePanel\n },\n computed: {\n showFeaturesPanel () { return this.$store.state.instance.showFeaturesPanel }\n }\n}\n\nexport default About\n","const InstanceSpecificPanel = {\n computed: {\n instanceSpecificPanelContent () {\n return this.$store.state.instance.instanceSpecificPanelContent\n }\n }\n}\n\nexport default InstanceSpecificPanel\n","const FeaturesPanel = {\n computed: {\n chat: function () { return this.$store.state.instance.chatAvailable },\n gopher: function () { return this.$store.state.instance.gopherAvailable },\n whoToFollow: function () { return this.$store.state.instance.suggestionsEnabled },\n mediaProxy: function () { return this.$store.state.instance.mediaProxyAvailable },\n minimalScopesMode: function () { return this.$store.state.instance.minimalScopesMode },\n textlimit: function () { return this.$store.state.instance.textlimit }\n }\n}\n\nexport default FeaturesPanel\n","const TermsOfServicePanel = {\n computed: {\n content () {\n return this.$store.state.instance.tos\n }\n }\n}\n\nexport default TermsOfServicePanel\n","const RemoteUserResolver = {\n data: () => ({\n error: false\n }),\n mounted () {\n this.redirect()\n },\n methods: {\n redirect () {\n const acct = this.$route.params.username + '@' + this.$route.params.hostname\n this.$store.state.api.backendInteractor.fetchUser({ id: acct })\n .then((externalUser) => {\n if (externalUser.error) {\n this.error = true\n } else {\n this.$store.commit('addNewUsers', [externalUser])\n const id = externalUser.id\n this.$router.replace({\n name: 'external-user-profile',\n params: { id }\n })\n }\n })\n .catch(() => {\n this.error = true\n })\n }\n }\n}\n\nexport default RemoteUserResolver\n","import UserPanel from './components/user_panel/user_panel.vue'\nimport NavPanel from './components/nav_panel/nav_panel.vue'\nimport Notifications from './components/notifications/notifications.vue'\nimport SearchBar from './components/search_bar/search_bar.vue'\nimport InstanceSpecificPanel from './components/instance_specific_panel/instance_specific_panel.vue'\nimport FeaturesPanel from './components/features_panel/features_panel.vue'\nimport WhoToFollowPanel from './components/who_to_follow_panel/who_to_follow_panel.vue'\nimport ChatPanel from './components/chat_panel/chat_panel.vue'\nimport MediaModal from './components/media_modal/media_modal.vue'\nimport SideDrawer from './components/side_drawer/side_drawer.vue'\nimport MobilePostStatusButton from './components/mobile_post_status_button/mobile_post_status_button.vue'\nimport MobileNav from './components/mobile_nav/mobile_nav.vue'\nimport UserReportingModal from './components/user_reporting_modal/user_reporting_modal.vue'\nimport PostStatusModal from './components/post_status_modal/post_status_modal.vue'\nimport { windowWidth } from './services/window_utils/window_utils'\n\nexport default {\n name: 'app',\n components: {\n UserPanel,\n NavPanel,\n Notifications,\n SearchBar,\n InstanceSpecificPanel,\n FeaturesPanel,\n WhoToFollowPanel,\n ChatPanel,\n MediaModal,\n SideDrawer,\n MobilePostStatusButton,\n MobileNav,\n UserReportingModal,\n PostStatusModal\n },\n data: () => ({\n mobileActivePanel: 'timeline',\n searchBarHidden: true,\n supportsMask: window.CSS && window.CSS.supports && (\n window.CSS.supports('mask-size', 'contain') ||\n window.CSS.supports('-webkit-mask-size', 'contain') ||\n window.CSS.supports('-moz-mask-size', 'contain') ||\n window.CSS.supports('-ms-mask-size', 'contain') ||\n window.CSS.supports('-o-mask-size', 'contain')\n )\n }),\n created () {\n // Load the locale from the storage\n this.$i18n.locale = this.$store.getters.mergedConfig.interfaceLanguage\n window.addEventListener('resize', this.updateMobileState)\n },\n destroyed () {\n window.removeEventListener('resize', this.updateMobileState)\n },\n computed: {\n currentUser () { return this.$store.state.users.currentUser },\n background () {\n return this.currentUser.background_image || this.$store.state.instance.background\n },\n enableMask () { return this.supportsMask && this.$store.state.instance.logoMask },\n logoStyle () {\n return {\n 'visibility': this.enableMask ? 'hidden' : 'visible'\n }\n },\n logoMaskStyle () {\n return this.enableMask ? {\n 'mask-image': `url(${this.$store.state.instance.logo})`\n } : {\n 'background-color': this.enableMask ? '' : 'transparent'\n }\n },\n logoBgStyle () {\n return Object.assign({\n 'margin': `${this.$store.state.instance.logoMargin} 0`,\n opacity: this.searchBarHidden ? 1 : 0\n }, this.enableMask ? {} : {\n 'background-color': this.enableMask ? '' : 'transparent'\n })\n },\n logo () { return this.$store.state.instance.logo },\n bgStyle () {\n return {\n 'background-image': `url(${this.background})`\n }\n },\n bgAppStyle () {\n return {\n '--body-background-image': `url(${this.background})`\n }\n },\n sitename () { return this.$store.state.instance.name },\n chat () { return this.$store.state.chat.channel.state === 'joined' },\n suggestionsEnabled () { return this.$store.state.instance.suggestionsEnabled },\n showInstanceSpecificPanel () {\n return this.$store.state.instance.showInstanceSpecificPanel &&\n !this.$store.getters.mergedConfig.hideISP &&\n this.$store.state.instance.instanceSpecificPanelContent\n },\n showFeaturesPanel () { return this.$store.state.instance.showFeaturesPanel },\n isMobileLayout () { return this.$store.state.interface.mobileLayout }\n },\n methods: {\n scrollToTop () {\n window.scrollTo(0, 0)\n },\n logout () {\n this.$router.replace('/main/public')\n this.$store.dispatch('logout')\n },\n onSearchBarToggled (hidden) {\n this.searchBarHidden = hidden\n },\n updateMobileState () {\n const mobileLayout = windowWidth() <= 800\n const changed = mobileLayout !== this.isMobileLayout\n if (changed) {\n this.$store.dispatch('setMobileLayout', mobileLayout)\n }\n }\n }\n}\n","import AuthForm from '../auth_form/auth_form.js'\nimport PostStatusForm from '../post_status_form/post_status_form.vue'\nimport UserCard from '../user_card/user_card.vue'\nimport { mapState } from 'vuex'\n\nconst UserPanel = {\n computed: {\n signedIn () { return this.user },\n ...mapState({ user: state => state.users.currentUser })\n },\n components: {\n AuthForm,\n PostStatusForm,\n UserCard\n }\n}\n\nexport default UserPanel\n","import followRequestFetcher from '../../services/follow_request_fetcher/follow_request_fetcher.service'\n\nconst NavPanel = {\n created () {\n if (this.currentUser && this.currentUser.locked) {\n const store = this.$store\n const credentials = store.state.users.currentUser.credentials\n\n followRequestFetcher.startFetching({ store, credentials })\n }\n },\n computed: {\n currentUser () {\n return this.$store.state.users.currentUser\n },\n chat () {\n return this.$store.state.chat.channel\n },\n followRequestCount () {\n return this.$store.state.api.followRequests.length\n }\n }\n}\n\nexport default NavPanel\n","const SearchBar = {\n data: () => ({\n searchTerm: undefined,\n hidden: true,\n error: false,\n loading: false\n }),\n watch: {\n '$route': function (route) {\n if (route.name === 'search') {\n this.searchTerm = route.query.query\n }\n }\n },\n methods: {\n find (searchTerm) {\n this.$router.push({ name: 'search', query: { query: searchTerm } })\n this.$refs.searchInput.focus()\n },\n toggleHidden () {\n this.hidden = !this.hidden\n this.$emit('toggled', this.hidden)\n this.$nextTick(() => {\n if (!this.hidden) {\n this.$refs.searchInput.focus()\n }\n })\n }\n }\n}\n\nexport default SearchBar\n","import apiService from '../../services/api/api.service.js'\nimport generateProfileLink from 'src/services/user_profile_link_generator/user_profile_link_generator'\nimport { shuffle } from 'lodash'\n\nfunction showWhoToFollow (panel, reply) {\n const shuffled = shuffle(reply)\n\n panel.usersToFollow.forEach((toFollow, index) => {\n let user = shuffled[index]\n let img = user.avatar || '/images/avi.png'\n let name = user.acct\n\n toFollow.img = img\n toFollow.name = name\n\n panel.$store.state.api.backendInteractor.fetchUser({ id: name })\n .then((externalUser) => {\n if (!externalUser.error) {\n panel.$store.commit('addNewUsers', [externalUser])\n toFollow.id = externalUser.id\n }\n })\n })\n}\n\nfunction getWhoToFollow (panel) {\n var credentials = panel.$store.state.users.currentUser.credentials\n if (credentials) {\n panel.usersToFollow.forEach(toFollow => {\n toFollow.name = 'Loading...'\n })\n apiService.suggestions({ credentials: credentials })\n .then((reply) => {\n showWhoToFollow(panel, reply)\n })\n }\n}\n\nconst WhoToFollowPanel = {\n data: () => ({\n usersToFollow: new Array(3).fill().map(x => (\n {\n img: '/images/avi.png',\n name: '',\n id: 0\n }\n ))\n }),\n computed: {\n user: function () {\n return this.$store.state.users.currentUser.screen_name\n },\n suggestionsEnabled () {\n return this.$store.state.instance.suggestionsEnabled\n }\n },\n methods: {\n userProfileLink (id, name) {\n return generateProfileLink(id, name, this.$store.state.instance.restrictedNicknames)\n }\n },\n watch: {\n user: function (user, oldUser) {\n if (this.suggestionsEnabled) {\n getWhoToFollow(this)\n }\n }\n },\n mounted:\n function () {\n if (this.suggestionsEnabled) {\n getWhoToFollow(this)\n }\n }\n}\n\nexport default WhoToFollowPanel\n","import StillImage from '../still-image/still-image.vue'\nimport VideoAttachment from '../video_attachment/video_attachment.vue'\nimport Modal from '../modal/modal.vue'\nimport fileTypeService from '../../services/file_type/file_type.service.js'\nimport GestureService from '../../services/gesture_service/gesture_service'\n\nconst MediaModal = {\n components: {\n StillImage,\n VideoAttachment,\n Modal\n },\n computed: {\n showing () {\n return this.$store.state.mediaViewer.activated\n },\n media () {\n return this.$store.state.mediaViewer.media\n },\n currentIndex () {\n return this.$store.state.mediaViewer.currentIndex\n },\n currentMedia () {\n return this.media[this.currentIndex]\n },\n canNavigate () {\n return this.media.length > 1\n },\n type () {\n return this.currentMedia ? fileTypeService.fileType(this.currentMedia.mimetype) : null\n }\n },\n created () {\n this.mediaSwipeGestureRight = GestureService.swipeGesture(\n GestureService.DIRECTION_RIGHT,\n this.goPrev,\n 50\n )\n this.mediaSwipeGestureLeft = GestureService.swipeGesture(\n GestureService.DIRECTION_LEFT,\n this.goNext,\n 50\n )\n },\n methods: {\n mediaTouchStart (e) {\n GestureService.beginSwipe(e, this.mediaSwipeGestureRight)\n GestureService.beginSwipe(e, this.mediaSwipeGestureLeft)\n },\n mediaTouchMove (e) {\n GestureService.updateSwipe(e, this.mediaSwipeGestureRight)\n GestureService.updateSwipe(e, this.mediaSwipeGestureLeft)\n },\n hide () {\n this.$store.dispatch('closeMediaViewer')\n },\n goPrev () {\n if (this.canNavigate) {\n const prevIndex = this.currentIndex === 0 ? this.media.length - 1 : (this.currentIndex - 1)\n this.$store.dispatch('setCurrent', this.media[prevIndex])\n }\n },\n goNext () {\n if (this.canNavigate) {\n const nextIndex = this.currentIndex === this.media.length - 1 ? 0 : (this.currentIndex + 1)\n this.$store.dispatch('setCurrent', this.media[nextIndex])\n }\n },\n handleKeyupEvent (e) {\n if (this.showing && e.keyCode === 27) { // escape\n this.hide()\n }\n },\n handleKeydownEvent (e) {\n if (!this.showing) {\n return\n }\n\n if (e.keyCode === 39) { // arrow right\n this.goNext()\n } else if (e.keyCode === 37) { // arrow left\n this.goPrev()\n }\n }\n },\n mounted () {\n document.addEventListener('keyup', this.handleKeyupEvent)\n document.addEventListener('keydown', this.handleKeydownEvent)\n },\n destroyed () {\n document.removeEventListener('keyup', this.handleKeyupEvent)\n document.removeEventListener('keydown', this.handleKeydownEvent)\n }\n}\n\nexport default MediaModal\n","\n\n\n\n\n","import UserCard from '../user_card/user_card.vue'\nimport { unseenNotificationsFromStore } from '../../services/notification_utils/notification_utils'\nimport GestureService from '../../services/gesture_service/gesture_service'\n\nconst SideDrawer = {\n props: [ 'logout' ],\n data: () => ({\n closed: true,\n closeGesture: undefined\n }),\n created () {\n this.closeGesture = GestureService.swipeGesture(GestureService.DIRECTION_LEFT, this.toggleDrawer)\n },\n components: { UserCard },\n computed: {\n currentUser () {\n return this.$store.state.users.currentUser\n },\n chat () { return this.$store.state.chat.channel.state === 'joined' },\n unseenNotifications () {\n return unseenNotificationsFromStore(this.$store)\n },\n unseenNotificationsCount () {\n return this.unseenNotifications.length\n },\n suggestionsEnabled () {\n return this.$store.state.instance.suggestionsEnabled\n },\n logo () {\n return this.$store.state.instance.logo\n },\n sitename () {\n return this.$store.state.instance.name\n },\n followRequestCount () {\n return this.$store.state.api.followRequests.length\n }\n },\n methods: {\n toggleDrawer () {\n this.closed = !this.closed\n },\n doLogout () {\n this.logout()\n this.toggleDrawer()\n },\n touchStart (e) {\n GestureService.beginSwipe(e, this.closeGesture)\n },\n touchMove (e) {\n GestureService.updateSwipe(e, this.closeGesture)\n }\n }\n}\n\nexport default SideDrawer\n","import { debounce } from 'lodash'\n\nconst MobilePostStatusButton = {\n data () {\n return {\n hidden: false,\n scrollingDown: false,\n inputActive: false,\n oldScrollPos: 0,\n amountScrolled: 0\n }\n },\n created () {\n if (this.autohideFloatingPostButton) {\n this.activateFloatingPostButtonAutohide()\n }\n window.addEventListener('resize', this.handleOSK)\n },\n destroyed () {\n if (this.autohideFloatingPostButton) {\n this.deactivateFloatingPostButtonAutohide()\n }\n window.removeEventListener('resize', this.handleOSK)\n },\n computed: {\n isLoggedIn () {\n return !!this.$store.state.users.currentUser\n },\n isHidden () {\n return this.autohideFloatingPostButton && (this.hidden || this.inputActive)\n },\n autohideFloatingPostButton () {\n return !!this.$store.getters.mergedConfig.autohideFloatingPostButton\n }\n },\n watch: {\n autohideFloatingPostButton: function (isEnabled) {\n if (isEnabled) {\n this.activateFloatingPostButtonAutohide()\n } else {\n this.deactivateFloatingPostButtonAutohide()\n }\n }\n },\n methods: {\n activateFloatingPostButtonAutohide () {\n window.addEventListener('scroll', this.handleScrollStart)\n window.addEventListener('scroll', this.handleScrollEnd)\n },\n deactivateFloatingPostButtonAutohide () {\n window.removeEventListener('scroll', this.handleScrollStart)\n window.removeEventListener('scroll', this.handleScrollEnd)\n },\n openPostForm () {\n this.$store.dispatch('openPostStatusModal')\n },\n handleOSK () {\n // This is a big hack: we're guessing from changed window sizes if the\n // on-screen keyboard is active or not. This is only really important\n // for phones in portrait mode and it's more important to show the button\n // in normal scenarios on all phones, than it is to hide it when the\n // keyboard is active.\n // Guesswork based on https://www.mydevice.io/#compare-devices\n\n // for example, iphone 4 and android phones from the same time period\n const smallPhone = window.innerWidth < 350\n const smallPhoneKbOpen = smallPhone && window.innerHeight < 345\n\n const biggerPhone = !smallPhone && window.innerWidth < 450\n const biggerPhoneKbOpen = biggerPhone && window.innerHeight < 560\n if (smallPhoneKbOpen || biggerPhoneKbOpen) {\n this.inputActive = true\n } else {\n this.inputActive = false\n }\n },\n handleScrollStart: debounce(function () {\n if (window.scrollY > this.oldScrollPos) {\n this.hidden = true\n } else {\n this.hidden = false\n }\n this.oldScrollPos = window.scrollY\n }, 100, { leading: true, trailing: false }),\n\n handleScrollEnd: debounce(function () {\n this.hidden = false\n this.oldScrollPos = window.scrollY\n }, 100, { leading: false, trailing: true })\n }\n}\n\nexport default MobilePostStatusButton\n","import SideDrawer from '../side_drawer/side_drawer.vue'\nimport Notifications from '../notifications/notifications.vue'\nimport { unseenNotificationsFromStore } from '../../services/notification_utils/notification_utils'\nimport GestureService from '../../services/gesture_service/gesture_service'\n\nconst MobileNav = {\n components: {\n SideDrawer,\n Notifications\n },\n data: () => ({\n notificationsCloseGesture: undefined,\n notificationsOpen: false\n }),\n created () {\n this.notificationsCloseGesture = GestureService.swipeGesture(\n GestureService.DIRECTION_RIGHT,\n this.closeMobileNotifications,\n 50\n )\n },\n computed: {\n currentUser () {\n return this.$store.state.users.currentUser\n },\n unseenNotifications () {\n return unseenNotificationsFromStore(this.$store)\n },\n unseenNotificationsCount () {\n return this.unseenNotifications.length\n },\n sitename () { return this.$store.state.instance.name }\n },\n methods: {\n toggleMobileSidebar () {\n this.$refs.sideDrawer.toggleDrawer()\n },\n openMobileNotifications () {\n this.notificationsOpen = true\n },\n closeMobileNotifications () {\n if (this.notificationsOpen) {\n // make sure to mark notifs seen only when the notifs were open and not\n // from close-calls.\n this.notificationsOpen = false\n this.markNotificationsAsSeen()\n }\n },\n notificationsTouchStart (e) {\n GestureService.beginSwipe(e, this.notificationsCloseGesture)\n },\n notificationsTouchMove (e) {\n GestureService.updateSwipe(e, this.notificationsCloseGesture)\n },\n scrollToTop () {\n window.scrollTo(0, 0)\n },\n logout () {\n this.$router.replace('/main/public')\n this.$store.dispatch('logout')\n },\n markNotificationsAsSeen () {\n this.$refs.notifications.markAsSeen()\n },\n onScroll ({ target: { scrollTop, clientHeight, scrollHeight } }) {\n if (this.$store.getters.mergedConfig.autoLoad && scrollTop + clientHeight >= scrollHeight) {\n this.$refs.notifications.fetchOlderNotifications()\n }\n }\n },\n watch: {\n $route () {\n // handles closing notificaitons when you press any router-link on the\n // notifications.\n this.closeMobileNotifications()\n }\n }\n}\n\nexport default MobileNav\n","\nimport Status from '../status/status.vue'\nimport List from '../list/list.vue'\nimport Checkbox from '../checkbox/checkbox.vue'\nimport Modal from '../modal/modal.vue'\n\nconst UserReportingModal = {\n components: {\n Status,\n List,\n Checkbox,\n Modal\n },\n data () {\n return {\n comment: '',\n forward: false,\n statusIdsToReport: [],\n processing: false,\n error: false\n }\n },\n computed: {\n isLoggedIn () {\n return !!this.$store.state.users.currentUser\n },\n isOpen () {\n return this.isLoggedIn && this.$store.state.reports.modalActivated\n },\n userId () {\n return this.$store.state.reports.userId\n },\n user () {\n return this.$store.getters.findUser(this.userId)\n },\n remoteInstance () {\n return !this.user.is_local && this.user.screen_name.substr(this.user.screen_name.indexOf('@') + 1)\n },\n statuses () {\n return this.$store.state.reports.statuses\n }\n },\n watch: {\n userId: 'resetState'\n },\n methods: {\n resetState () {\n // Reset state\n this.comment = ''\n this.forward = false\n this.statusIdsToReport = []\n this.processing = false\n this.error = false\n },\n closeModal () {\n this.$store.dispatch('closeUserReportingModal')\n },\n reportUser () {\n this.processing = true\n this.error = false\n const params = {\n userId: this.userId,\n comment: this.comment,\n forward: this.forward,\n statusIds: this.statusIdsToReport\n }\n this.$store.state.api.backendInteractor.reportUser(params)\n .then(() => {\n this.processing = false\n this.resetState()\n this.closeModal()\n })\n .catch(() => {\n this.processing = false\n this.error = true\n })\n },\n clearError () {\n this.error = false\n },\n isChecked (statusId) {\n return this.statusIdsToReport.indexOf(statusId) !== -1\n },\n toggleStatus (checked, statusId) {\n if (checked === this.isChecked(statusId)) {\n return\n }\n\n if (checked) {\n this.statusIdsToReport.push(statusId)\n } else {\n this.statusIdsToReport.splice(this.statusIdsToReport.indexOf(statusId), 1)\n }\n },\n resize (e) {\n const target = e.target || e\n if (!(target instanceof window.Element)) { return }\n // Auto is needed to make textbox shrink when removing lines\n target.style.height = 'auto'\n target.style.height = `${target.scrollHeight}px`\n if (target.value === '') {\n target.style.height = null\n }\n }\n }\n}\n\nexport default UserReportingModal\n","import PostStatusForm from '../post_status_form/post_status_form.vue'\nimport Modal from '../modal/modal.vue'\nimport get from 'lodash/get'\n\nconst PostStatusModal = {\n components: {\n PostStatusForm,\n Modal\n },\n data () {\n return {\n resettingForm: false\n }\n },\n computed: {\n isLoggedIn () {\n return !!this.$store.state.users.currentUser\n },\n modalActivated () {\n return this.$store.state.postStatus.modalActivated\n },\n isFormVisible () {\n return this.isLoggedIn && !this.resettingForm && this.modalActivated\n },\n params () {\n return this.$store.state.postStatus.params || {}\n }\n },\n watch: {\n params (newVal, oldVal) {\n if (get(newVal, 'repliedUser.id') !== get(oldVal, 'repliedUser.id')) {\n this.resettingForm = true\n this.$nextTick(() => {\n this.resettingForm = false\n })\n }\n },\n isFormVisible (val) {\n if (val) {\n this.$nextTick(() => this.$el && this.$el.querySelector('textarea').focus())\n }\n }\n },\n methods: {\n closeModal () {\n this.$store.dispatch('closePostStatusModal')\n }\n }\n}\n\nexport default PostStatusModal\n","import Vue from 'vue'\n\nimport './tab_switcher.scss'\n\nexport default Vue.component('tab-switcher', {\n name: 'TabSwitcher',\n props: {\n renderOnlyFocused: {\n required: false,\n type: Boolean,\n default: false\n },\n onSwitch: {\n required: false,\n type: Function,\n default: undefined\n },\n activeTab: {\n required: false,\n type: String,\n default: undefined\n },\n scrollableTabs: {\n required: false,\n type: Boolean,\n default: false\n }\n },\n data () {\n return {\n active: this.$slots.default.findIndex(_ => _.tag)\n }\n },\n computed: {\n activeIndex () {\n // In case of controlled component\n if (this.activeTab) {\n return this.$slots.default.findIndex(slot => this.activeTab === slot.key)\n } else {\n return this.active\n }\n }\n },\n beforeUpdate () {\n const currentSlot = this.$slots.default[this.active]\n if (!currentSlot.tag) {\n this.active = this.$slots.default.findIndex(_ => _.tag)\n }\n },\n methods: {\n activateTab (index) {\n return (e) => {\n e.preventDefault()\n if (typeof this.onSwitch === 'function') {\n this.onSwitch.call(null, this.$slots.default[index].key)\n }\n this.active = index\n }\n }\n },\n render (h) {\n const tabs = this.$slots.default\n .map((slot, index) => {\n if (!slot.tag) return\n const classesTab = ['tab']\n const classesWrapper = ['tab-wrapper']\n\n if (this.activeIndex === index) {\n classesTab.push('active')\n classesWrapper.push('active')\n }\n if (slot.data.attrs.image) {\n return (\n
\n \n \n {slot.data.attrs.label ? '' : slot.data.attrs.label}\n \n
\n )\n }\n return (\n
\n \n {slot.data.attrs.label}\n
\n )\n })\n\n const contents = this.$slots.default.map((slot, index) => {\n if (!slot.tag) return\n const active = this.activeIndex === index\n if (this.renderOnlyFocused) {\n return active\n ?
{slot}
\n :
\n }\n return
{slot}
\n })\n\n return (\n
\n
\n {tabs}\n
\n
\n {contents}\n
\n
\n )\n }\n})\n","import { set, delete as del } from 'vue'\nimport { setPreset, applyTheme } from '../services/style_setter/style_setter.js'\n\nconst browserLocale = (window.navigator.language || 'en').split('-')[0]\n\nexport const defaultState = {\n colors: {},\n // bad name: actually hides posts of muted USERS\n hideMutedPosts: undefined, // instance default\n collapseMessageWithSubject: undefined, // instance default\n padEmoji: true,\n hideAttachments: false,\n hideAttachmentsInConv: false,\n maxThumbnails: 16,\n hideNsfw: true,\n preloadImage: true,\n loopVideo: true,\n loopVideoSilentOnly: true,\n autoLoad: true,\n streaming: false,\n hoverPreview: true,\n autohideFloatingPostButton: false,\n pauseOnUnfocused: true,\n stopGifs: false,\n replyVisibility: 'all',\n notificationVisibility: {\n follows: true,\n mentions: true,\n likes: true,\n repeats: true\n },\n webPushNotifications: false,\n muteWords: [],\n highlight: {},\n interfaceLanguage: browserLocale,\n hideScopeNotice: false,\n scopeCopy: undefined, // instance default\n subjectLineBehavior: undefined, // instance default\n alwaysShowSubjectInput: undefined, // instance default\n postContentType: undefined, // instance default\n minimalScopesMode: undefined, // instance default\n // This hides statuses filtered via a word filter\n hideFilteredStatuses: undefined, // instance default\n playVideosInModal: false,\n useOneClickNsfw: false,\n useContainFit: false,\n hidePostStats: undefined, // instance default\n hideUserStats: undefined // instance default\n}\n\n// caching the instance default properties\nexport const instanceDefaultProperties = Object.entries(defaultState)\n .filter(([key, value]) => value === undefined)\n .map(([key, value]) => key)\n\nconst config = {\n state: defaultState,\n getters: {\n mergedConfig (state, getters, rootState, rootGetters) {\n const { instance } = rootState\n return {\n ...state,\n ...instanceDefaultProperties\n .map(key => [key, state[key] === undefined\n ? instance[key]\n : state[key]\n ])\n .reduce((acc, [key, value]) => ({ ...acc, [key]: value }), {})\n }\n }\n },\n mutations: {\n setOption (state, { name, value }) {\n set(state, name, value)\n },\n setHighlight (state, { user, color, type }) {\n const data = this.state.config.highlight[user]\n if (color || type) {\n set(state.highlight, user, { color: color || data.color, type: type || data.type })\n } else {\n del(state.highlight, user)\n }\n }\n },\n actions: {\n setHighlight ({ commit, dispatch }, { user, color, type }) {\n commit('setHighlight', { user, color, type })\n },\n setOption ({ commit, dispatch }, { name, value }) {\n commit('setOption', { name, value })\n switch (name) {\n case 'theme':\n setPreset(value, commit)\n break\n case 'customTheme':\n applyTheme(value, commit)\n }\n }\n }\n}\n\nexport default config\n","import apiService from '../api/api.service.js'\nimport timelineFetcherService from '../timeline_fetcher/timeline_fetcher.service.js'\nimport notificationsFetcher from '../notifications_fetcher/notifications_fetcher.service.js'\n\nconst backendInteractorService = credentials => {\n const fetchStatus = ({ id }) => {\n return apiService.fetchStatus({ id, credentials })\n }\n\n const fetchConversation = ({ id }) => {\n return apiService.fetchConversation({ id, credentials })\n }\n\n const fetchFriends = ({ id, maxId, sinceId, limit }) => {\n return apiService.fetchFriends({ id, maxId, sinceId, limit, credentials })\n }\n\n const exportFriends = ({ id }) => {\n return apiService.exportFriends({ id, credentials })\n }\n\n const fetchFollowers = ({ id, maxId, sinceId, limit }) => {\n return apiService.fetchFollowers({ id, maxId, sinceId, limit, credentials })\n }\n\n const fetchUser = ({ id }) => {\n return apiService.fetchUser({ id, credentials })\n }\n\n const fetchUserRelationship = ({ id }) => {\n return apiService.fetchUserRelationship({ id, credentials })\n }\n\n const followUser = ({ id, reblogs }) => {\n return apiService.followUser({ credentials, id, reblogs })\n }\n\n const unfollowUser = (id) => {\n return apiService.unfollowUser({ credentials, id })\n }\n\n const blockUser = (id) => {\n return apiService.blockUser({ credentials, id })\n }\n\n const unblockUser = (id) => {\n return apiService.unblockUser({ credentials, id })\n }\n\n const approveUser = (id) => {\n return apiService.approveUser({ credentials, id })\n }\n\n const denyUser = (id) => {\n return apiService.denyUser({ credentials, id })\n }\n\n const startFetchingTimeline = ({ timeline, store, userId = false, tag }) => {\n return timelineFetcherService.startFetching({ timeline, store, credentials, userId, tag })\n }\n\n const startFetchingNotifications = ({ store }) => {\n return notificationsFetcher.startFetching({ store, credentials })\n }\n\n // eslint-disable-next-line camelcase\n const tagUser = ({ screen_name }, tag) => {\n return apiService.tagUser({ screen_name, tag, credentials })\n }\n\n // eslint-disable-next-line camelcase\n const untagUser = ({ screen_name }, tag) => {\n return apiService.untagUser({ screen_name, tag, credentials })\n }\n\n // eslint-disable-next-line camelcase\n const addRight = ({ screen_name }, right) => {\n return apiService.addRight({ screen_name, right, credentials })\n }\n\n // eslint-disable-next-line camelcase\n const deleteRight = ({ screen_name }, right) => {\n return apiService.deleteRight({ screen_name, right, credentials })\n }\n\n // eslint-disable-next-line camelcase\n const setActivationStatus = ({ screen_name }, status) => {\n return apiService.setActivationStatus({ screen_name, status, credentials })\n }\n\n // eslint-disable-next-line camelcase\n const deleteUser = ({ screen_name }) => {\n return apiService.deleteUser({ screen_name, credentials })\n }\n\n const vote = (pollId, choices) => {\n return apiService.vote({ credentials, pollId, choices })\n }\n\n const fetchPoll = (pollId) => {\n return apiService.fetchPoll({ credentials, pollId })\n }\n\n const updateNotificationSettings = ({ settings }) => {\n return apiService.updateNotificationSettings({ credentials, settings })\n }\n\n const fetchMutes = () => apiService.fetchMutes({ credentials })\n const muteUser = (id) => apiService.muteUser({ credentials, id })\n const unmuteUser = (id) => apiService.unmuteUser({ credentials, id })\n const subscribeUser = (id) => apiService.subscribeUser({ credentials, id })\n const unsubscribeUser = (id) => apiService.unsubscribeUser({ credentials, id })\n const fetchBlocks = () => apiService.fetchBlocks({ credentials })\n const fetchFollowRequests = () => apiService.fetchFollowRequests({ credentials })\n const fetchOAuthTokens = () => apiService.fetchOAuthTokens({ credentials })\n const revokeOAuthToken = (id) => apiService.revokeOAuthToken({ id, credentials })\n const fetchPinnedStatuses = (id) => apiService.fetchPinnedStatuses({ credentials, id })\n const pinOwnStatus = (id) => apiService.pinOwnStatus({ credentials, id })\n const unpinOwnStatus = (id) => apiService.unpinOwnStatus({ credentials, id })\n const muteConversation = (id) => apiService.muteConversation({ credentials, id })\n const unmuteConversation = (id) => apiService.unmuteConversation({ credentials, id })\n\n const getCaptcha = () => apiService.getCaptcha()\n const register = (params) => apiService.register({ credentials, params })\n const updateAvatar = ({ avatar }) => apiService.updateAvatar({ credentials, avatar })\n const updateBg = ({ background }) => apiService.updateBg({ credentials, background })\n const updateBanner = ({ banner }) => apiService.updateBanner({ credentials, banner })\n const updateProfile = ({ params }) => apiService.updateProfile({ credentials, params })\n\n const importBlocks = (file) => apiService.importBlocks({ file, credentials })\n const importFollows = (file) => apiService.importFollows({ file, credentials })\n\n const deleteAccount = ({ password }) => apiService.deleteAccount({ credentials, password })\n const changeEmail = ({ email, password }) => apiService.changeEmail({ credentials, email, password })\n const changePassword = ({ password, newPassword, newPasswordConfirmation }) =>\n apiService.changePassword({ credentials, password, newPassword, newPasswordConfirmation })\n\n const fetchSettingsMFA = () => apiService.settingsMFA({ credentials })\n const generateMfaBackupCodes = () => apiService.generateMfaBackupCodes({ credentials })\n const mfaSetupOTP = () => apiService.mfaSetupOTP({ credentials })\n const mfaConfirmOTP = ({ password, token }) => apiService.mfaConfirmOTP({ credentials, password, token })\n const mfaDisableOTP = ({ password }) => apiService.mfaDisableOTP({ credentials, password })\n\n const fetchFavoritedByUsers = (id) => apiService.fetchFavoritedByUsers({ id })\n const fetchRebloggedByUsers = (id) => apiService.fetchRebloggedByUsers({ id })\n const reportUser = (params) => apiService.reportUser({ credentials, ...params })\n\n const favorite = (id) => apiService.favorite({ id, credentials })\n const unfavorite = (id) => apiService.unfavorite({ id, credentials })\n const retweet = (id) => apiService.retweet({ id, credentials })\n const unretweet = (id) => apiService.unretweet({ id, credentials })\n const search2 = ({ q, resolve, limit, offset, following }) =>\n apiService.search2({ credentials, q, resolve, limit, offset, following })\n const searchUsers = (query) => apiService.searchUsers({ query, credentials })\n\n const backendInteractorServiceInstance = {\n fetchStatus,\n fetchConversation,\n fetchFriends,\n exportFriends,\n fetchFollowers,\n followUser,\n unfollowUser,\n blockUser,\n unblockUser,\n fetchUser,\n fetchUserRelationship,\n verifyCredentials: apiService.verifyCredentials,\n startFetchingTimeline,\n startFetchingNotifications,\n fetchMutes,\n muteUser,\n unmuteUser,\n subscribeUser,\n unsubscribeUser,\n fetchBlocks,\n fetchOAuthTokens,\n revokeOAuthToken,\n fetchPinnedStatuses,\n pinOwnStatus,\n unpinOwnStatus,\n muteConversation,\n unmuteConversation,\n tagUser,\n untagUser,\n addRight,\n deleteRight,\n deleteUser,\n setActivationStatus,\n register,\n getCaptcha,\n updateAvatar,\n updateBg,\n updateBanner,\n updateProfile,\n importBlocks,\n importFollows,\n deleteAccount,\n changeEmail,\n changePassword,\n fetchSettingsMFA,\n generateMfaBackupCodes,\n mfaSetupOTP,\n mfaConfirmOTP,\n mfaDisableOTP,\n fetchFollowRequests,\n approveUser,\n denyUser,\n vote,\n fetchPoll,\n fetchFavoritedByUsers,\n fetchRebloggedByUsers,\n reportUser,\n favorite,\n unfavorite,\n retweet,\n unretweet,\n updateNotificationSettings,\n search2,\n searchUsers\n }\n\n return backendInteractorServiceInstance\n}\n\nexport default backendInteractorService\n","function injectStyle (context) {\n require(\"!!vue-style-loader!css-loader?minimize!../../../node_modules/vue-loader/lib/style-compiler/index?{\\\"optionsId\\\":\\\"0\\\",\\\"vue\\\":true,\\\"scoped\\\":false,\\\"sourceMap\\\":false}!sass-loader!../../../node_modules/vue-loader/lib/selector?type=styles&index=0!./still-image.vue\")\n}\n/* script */\nexport * from \"!!babel-loader!./still-image.js\"\nimport __vue_script__ from \"!!babel-loader!./still-image.js\"/* template */\nimport {render as __vue_render__, staticRenderFns as __vue_static_render_fns__} from \"!!../../../node_modules/vue-loader/lib/template-compiler/index?{\\\"id\\\":\\\"data-v-1bc509fc\\\",\\\"hasScoped\\\":false,\\\"optionsId\\\":\\\"0\\\",\\\"buble\\\":{\\\"transforms\\\":{}}}!../../../node_modules/vue-loader/lib/selector?type=template&index=0!./still-image.vue\"\n/* template functional */\nvar __vue_template_functional__ = false\n/* styles */\nvar __vue_styles__ = injectStyle\n/* scopeId */\nvar __vue_scopeId__ = null\n/* moduleIdentifier (server only) */\nvar __vue_module_identifier__ = null\nimport normalizeComponent from \"!../../../node_modules/vue-loader/lib/runtime/component-normalizer\"\nvar Component = normalizeComponent(\n __vue_script__,\n __vue_render__,\n __vue_static_render_fns__,\n __vue_template_functional__,\n __vue_styles__,\n __vue_scopeId__,\n __vue_module_identifier__\n)\n\nexport default Component.exports\n","/* script */\nexport * from \"!!babel-loader!../../../node_modules/vue-loader/lib/selector?type=script&index=0!./timeago.vue\"\nimport __vue_script__ from \"!!babel-loader!../../../node_modules/vue-loader/lib/selector?type=script&index=0!./timeago.vue\"\n/* template */\nimport {render as __vue_render__, staticRenderFns as __vue_static_render_fns__} from \"!!../../../node_modules/vue-loader/lib/template-compiler/index?{\\\"id\\\":\\\"data-v-ac499830\\\",\\\"hasScoped\\\":false,\\\"optionsId\\\":\\\"0\\\",\\\"buble\\\":{\\\"transforms\\\":{}}}!../../../node_modules/vue-loader/lib/selector?type=template&index=0!./timeago.vue\"\n/* template functional */\nvar __vue_template_functional__ = false\n/* styles */\nvar __vue_styles__ = null\n/* scopeId */\nvar __vue_scopeId__ = null\n/* moduleIdentifier (server only) */\nvar __vue_module_identifier__ = null\nimport normalizeComponent from \"!../../../node_modules/vue-loader/lib/runtime/component-normalizer\"\nvar Component = normalizeComponent(\n __vue_script__,\n __vue_render__,\n __vue_static_render_fns__,\n __vue_template_functional__,\n __vue_styles__,\n __vue_scopeId__,\n __vue_module_identifier__\n)\n\nexport default Component.exports\n","function injectStyle (context) {\n require(\"!!vue-style-loader!css-loader?minimize!../../../node_modules/vue-loader/lib/style-compiler/index?{\\\"optionsId\\\":\\\"0\\\",\\\"vue\\\":true,\\\"scoped\\\":false,\\\"sourceMap\\\":false}!sass-loader!../../../node_modules/vue-loader/lib/selector?type=styles&index=0!./post_status_form.vue\")\n}\n/* script */\nexport * from \"!!babel-loader!./post_status_form.js\"\nimport __vue_script__ from \"!!babel-loader!./post_status_form.js\"/* template */\nimport {render as __vue_render__, staticRenderFns as __vue_static_render_fns__} from \"!!../../../node_modules/vue-loader/lib/template-compiler/index?{\\\"id\\\":\\\"data-v-f350f69c\\\",\\\"hasScoped\\\":false,\\\"optionsId\\\":\\\"0\\\",\\\"buble\\\":{\\\"transforms\\\":{}}}!../../../node_modules/vue-loader/lib/selector?type=template&index=0!./post_status_form.vue\"\n/* template functional */\nvar __vue_template_functional__ = false\n/* styles */\nvar __vue_styles__ = injectStyle\n/* scopeId */\nvar __vue_scopeId__ = null\n/* moduleIdentifier (server only) */\nvar __vue_module_identifier__ = null\nimport normalizeComponent from \"!../../../node_modules/vue-loader/lib/runtime/component-normalizer\"\nvar Component = normalizeComponent(\n __vue_script__,\n __vue_render__,\n __vue_static_render_fns__,\n __vue_template_functional__,\n __vue_styles__,\n __vue_scopeId__,\n __vue_module_identifier__\n)\n\nexport default Component.exports\n","/* script */\nexport * from \"!!babel-loader!../../../node_modules/vue-loader/lib/selector?type=script&index=0!./progress_button.vue\"\nimport __vue_script__ from \"!!babel-loader!../../../node_modules/vue-loader/lib/selector?type=script&index=0!./progress_button.vue\"\n/* template */\nimport {render as __vue_render__, staticRenderFns as __vue_static_render_fns__} from \"!!../../../node_modules/vue-loader/lib/template-compiler/index?{\\\"id\\\":\\\"data-v-9f751ae6\\\",\\\"hasScoped\\\":false,\\\"optionsId\\\":\\\"0\\\",\\\"buble\\\":{\\\"transforms\\\":{}}}!../../../node_modules/vue-loader/lib/selector?type=template&index=0!./progress_button.vue\"\n/* template functional */\nvar __vue_template_functional__ = false\n/* styles */\nvar __vue_styles__ = null\n/* scopeId */\nvar __vue_scopeId__ = null\n/* moduleIdentifier (server only) */\nvar __vue_module_identifier__ = null\nimport normalizeComponent from \"!../../../node_modules/vue-loader/lib/runtime/component-normalizer\"\nvar Component = normalizeComponent(\n __vue_script__,\n __vue_render__,\n __vue_static_render_fns__,\n __vue_template_functional__,\n __vue_styles__,\n __vue_scopeId__,\n __vue_module_identifier__\n)\n\nexport default Component.exports\n","import { filter, sortBy } from 'lodash'\n\nexport const notificationsFromStore = store => store.state.statuses.notifications.data\n\nexport const visibleTypes = store => ([\n store.state.config.notificationVisibility.likes && 'like',\n store.state.config.notificationVisibility.mentions && 'mention',\n store.state.config.notificationVisibility.repeats && 'repeat',\n store.state.config.notificationVisibility.follows && 'follow'\n].filter(_ => _))\n\nconst sortById = (a, b) => {\n const seqA = Number(a.id)\n const seqB = Number(b.id)\n const isSeqA = !Number.isNaN(seqA)\n const isSeqB = !Number.isNaN(seqB)\n if (isSeqA && isSeqB) {\n return seqA > seqB ? -1 : 1\n } else if (isSeqA && !isSeqB) {\n return 1\n } else if (!isSeqA && isSeqB) {\n return -1\n } else {\n return a.id > b.id ? -1 : 1\n }\n}\n\nexport const visibleNotificationsFromStore = (store, types) => {\n // map is just to clone the array since sort mutates it and it causes some issues\n let sortedNotifications = notificationsFromStore(store).map(_ => _).sort(sortById)\n sortedNotifications = sortBy(sortedNotifications, 'seen')\n return sortedNotifications.filter(\n (notification) => (types || visibleTypes(store)).includes(notification.type)\n )\n}\n\nexport const unseenNotificationsFromStore = store =>\n filter(visibleNotificationsFromStore(store), ({ seen }) => !seen)\n","function injectStyle (context) {\n require(\"!!vue-style-loader!css-loader?minimize!../../../node_modules/vue-loader/lib/style-compiler/index?{\\\"optionsId\\\":\\\"0\\\",\\\"vue\\\":true,\\\"scoped\\\":false,\\\"sourceMap\\\":false}!sass-loader!../../../node_modules/vue-loader/lib/selector?type=styles&index=0!./follow_card.vue\")\n}\n/* script */\nexport * from \"!!babel-loader!./follow_card.js\"\nimport __vue_script__ from \"!!babel-loader!./follow_card.js\"/* template */\nimport {render as __vue_render__, staticRenderFns as __vue_static_render_fns__} from \"!!../../../node_modules/vue-loader/lib/template-compiler/index?{\\\"id\\\":\\\"data-v-5b90ae69\\\",\\\"hasScoped\\\":false,\\\"optionsId\\\":\\\"0\\\",\\\"buble\\\":{\\\"transforms\\\":{}}}!../../../node_modules/vue-loader/lib/selector?type=template&index=0!./follow_card.vue\"\n/* template functional */\nvar __vue_template_functional__ = false\n/* styles */\nvar __vue_styles__ = injectStyle\n/* scopeId */\nvar __vue_scopeId__ = null\n/* moduleIdentifier (server only) */\nvar __vue_module_identifier__ = null\nimport normalizeComponent from \"!../../../node_modules/vue-loader/lib/runtime/component-normalizer\"\nvar Component = normalizeComponent(\n __vue_script__,\n __vue_render__,\n __vue_static_render_fns__,\n __vue_template_functional__,\n __vue_styles__,\n __vue_scopeId__,\n __vue_module_identifier__\n)\n\nexport default Component.exports\n","function injectStyle (context) {\n require(\"!!vue-style-loader!css-loader?minimize!../../../node_modules/vue-loader/lib/style-compiler/index?{\\\"optionsId\\\":\\\"0\\\",\\\"vue\\\":true,\\\"scoped\\\":false,\\\"sourceMap\\\":false}!sass-loader!../../../node_modules/vue-loader/lib/selector?type=styles&index=0!./list.vue\")\n}\n/* script */\nexport * from \"!!babel-loader!../../../node_modules/vue-loader/lib/selector?type=script&index=0!./list.vue\"\nimport __vue_script__ from \"!!babel-loader!../../../node_modules/vue-loader/lib/selector?type=script&index=0!./list.vue\"\n/* template */\nimport {render as __vue_render__, staticRenderFns as __vue_static_render_fns__} from \"!!../../../node_modules/vue-loader/lib/template-compiler/index?{\\\"id\\\":\\\"data-v-c1790f52\\\",\\\"hasScoped\\\":false,\\\"optionsId\\\":\\\"0\\\",\\\"buble\\\":{\\\"transforms\\\":{}}}!../../../node_modules/vue-loader/lib/selector?type=template&index=0!./list.vue\"\n/* template functional */\nvar __vue_template_functional__ = false\n/* styles */\nvar __vue_styles__ = injectStyle\n/* scopeId */\nvar __vue_scopeId__ = null\n/* moduleIdentifier (server only) */\nvar __vue_module_identifier__ = null\nimport normalizeComponent from \"!../../../node_modules/vue-loader/lib/runtime/component-normalizer\"\nvar Component = normalizeComponent(\n __vue_script__,\n __vue_render__,\n __vue_static_render_fns__,\n __vue_template_functional__,\n __vue_styles__,\n __vue_scopeId__,\n __vue_module_identifier__\n)\n\nexport default Component.exports\n","function injectStyle (context) {\n require(\"!!vue-style-loader!css-loader?minimize!../../../node_modules/vue-loader/lib/style-compiler/index?{\\\"optionsId\\\":\\\"0\\\",\\\"vue\\\":true,\\\"scoped\\\":false,\\\"sourceMap\\\":false}!sass-loader!../../../node_modules/vue-loader/lib/selector?type=styles&index=0!./modal.vue\")\n}\n/* script */\nexport * from \"!!babel-loader!../../../node_modules/vue-loader/lib/selector?type=script&index=0!./modal.vue\"\nimport __vue_script__ from \"!!babel-loader!../../../node_modules/vue-loader/lib/selector?type=script&index=0!./modal.vue\"\n/* template */\nimport {render as __vue_render__, staticRenderFns as __vue_static_render_fns__} from \"!!../../../node_modules/vue-loader/lib/template-compiler/index?{\\\"id\\\":\\\"data-v-068d175e\\\",\\\"hasScoped\\\":false,\\\"optionsId\\\":\\\"0\\\",\\\"buble\\\":{\\\"transforms\\\":{}}}!../../../node_modules/vue-loader/lib/selector?type=template&index=0!./modal.vue\"\n/* template functional */\nvar __vue_template_functional__ = false\n/* styles */\nvar __vue_styles__ = injectStyle\n/* scopeId */\nvar __vue_scopeId__ = null\n/* moduleIdentifier (server only) */\nvar __vue_module_identifier__ = null\nimport normalizeComponent from \"!../../../node_modules/vue-loader/lib/runtime/component-normalizer\"\nvar Component = normalizeComponent(\n __vue_script__,\n __vue_render__,\n __vue_static_render_fns__,\n __vue_template_functional__,\n __vue_styles__,\n __vue_scopeId__,\n __vue_module_identifier__\n)\n\nexport default Component.exports\n","\nconst DIRECTION_LEFT = [-1, 0]\nconst DIRECTION_RIGHT = [1, 0]\nconst DIRECTION_UP = [0, -1]\nconst DIRECTION_DOWN = [0, 1]\n\nconst deltaCoord = (oldCoord, newCoord) => [newCoord[0] - oldCoord[0], newCoord[1] - oldCoord[1]]\n\nconst touchEventCoord = e => ([e.touches[0].screenX, e.touches[0].screenY])\n\nconst vectorLength = v => Math.sqrt(v[0] * v[0] + v[1] * v[1])\n\nconst perpendicular = v => [v[1], -v[0]]\n\nconst dotProduct = (v1, v2) => v1[0] * v2[0] + v1[1] * v2[1]\n\nconst project = (v1, v2) => {\n const scalar = (dotProduct(v1, v2) / dotProduct(v2, v2))\n return [scalar * v2[0], scalar * v2[1]]\n}\n\n// direction: either use the constants above or an arbitrary 2d vector.\n// threshold: how many Px to move from touch origin before checking if the\n// callback should be called.\n// divergentTolerance: a scalar for much of divergent direction we tolerate when\n// above threshold. for example, with 1.0 we only call the callback if\n// divergent component of delta is < 1.0 * direction component of delta.\nconst swipeGesture = (direction, onSwipe, threshold = 30, perpendicularTolerance = 1.0) => {\n return {\n direction,\n onSwipe,\n threshold,\n perpendicularTolerance,\n _startPos: [0, 0],\n _swiping: false\n }\n}\n\nconst beginSwipe = (event, gesture) => {\n gesture._startPos = touchEventCoord(event)\n gesture._swiping = true\n}\n\nconst updateSwipe = (event, gesture) => {\n if (!gesture._swiping) return\n // movement too small\n const delta = deltaCoord(gesture._startPos, touchEventCoord(event))\n if (vectorLength(delta) < gesture.threshold) return\n // movement is opposite from direction\n if (dotProduct(delta, gesture.direction) < 0) return\n // movement perpendicular to direction is too much\n const towardsDir = project(delta, gesture.direction)\n const perpendicularDir = perpendicular(gesture.direction)\n const towardsPerpendicular = project(delta, perpendicularDir)\n if (\n vectorLength(towardsDir) * gesture.perpendicularTolerance <\n vectorLength(towardsPerpendicular)\n ) return\n\n gesture.onSwipe()\n gesture._swiping = false\n}\n\nconst GestureService = {\n DIRECTION_LEFT,\n DIRECTION_RIGHT,\n DIRECTION_UP,\n DIRECTION_DOWN,\n swipeGesture,\n beginSwipe,\n updateSwipe\n}\n\nexport default GestureService\n","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:\"still-image\",class:{ animated: _vm.animated }},[(_vm.animated)?_c('canvas',{ref:\"canvas\"}):_vm._e(),_vm._v(\" \"),_c('img',{key:_vm.src,ref:\"src\",attrs:{\"src\":_vm.src,\"referrerpolicy\":_vm.referrerpolicy},on:{\"load\":_vm.onLoad,\"error\":_vm.onError}})])}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('video',{staticClass:\"video\",attrs:{\"src\":_vm.attachment.url,\"loop\":_vm.loopVideo,\"controls\":_vm.controls,\"playsinline\":\"\"},on:{\"loadeddata\":_vm.onVideoDataLoad}})}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {\nvar _obj;\nvar _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return (_vm.usePlaceHolder)?_c('div',{on:{\"click\":_vm.openModal}},[(_vm.type !== 'html')?_c('a',{staticClass:\"placeholder\",attrs:{\"target\":\"_blank\",\"href\":_vm.attachment.url}},[_vm._v(\"\\n [\"+_vm._s(_vm.nsfw ? \"NSFW/\" : \"\")+_vm._s(_vm.type.toUpperCase())+\"]\\n \")]):_vm._e()]):_c('div',{directives:[{name:\"show\",rawName:\"v-show\",value:(!_vm.isEmpty),expression:\"!isEmpty\"}],staticClass:\"attachment\",class:( _obj = {}, _obj[_vm.type] = true, _obj.loading = _vm.loading, _obj['fullwidth'] = _vm.fullwidth, _obj['nsfw-placeholder'] = _vm.hidden, _obj )},[(_vm.hidden)?_c('a',{staticClass:\"image-attachment\",attrs:{\"href\":_vm.attachment.url},on:{\"click\":function($event){$event.preventDefault();return _vm.toggleHidden($event)}}},[_c('img',{key:_vm.nsfwImage,staticClass:\"nsfw\",class:{'small': _vm.isSmall},attrs:{\"src\":_vm.nsfwImage}}),_vm._v(\" \"),(_vm.type === 'video')?_c('i',{staticClass:\"play-icon icon-play-circled\"}):_vm._e()]):_vm._e(),_vm._v(\" \"),(_vm.nsfw && _vm.hideNsfwLocal && !_vm.hidden)?_c('div',{staticClass:\"hider\"},[_c('a',{attrs:{\"href\":\"#\"},on:{\"click\":function($event){$event.preventDefault();return _vm.toggleHidden($event)}}},[_vm._v(\"Hide\")])]):_vm._e(),_vm._v(\" \"),(_vm.type === 'image' && (!_vm.hidden || _vm.preloadImage))?_c('a',{staticClass:\"image-attachment\",class:{'hidden': _vm.hidden && _vm.preloadImage },attrs:{\"href\":_vm.attachment.url,\"target\":\"_blank\",\"title\":_vm.attachment.description},on:{\"click\":_vm.openModal}},[_c('StillImage',{attrs:{\"referrerpolicy\":_vm.referrerpolicy,\"mimetype\":_vm.attachment.mimetype,\"src\":_vm.attachment.large_thumb_url || _vm.attachment.url,\"image-load-handler\":_vm.onImageLoad}})],1):_vm._e(),_vm._v(\" \"),(_vm.type === 'video' && !_vm.hidden)?_c('a',{staticClass:\"video-container\",class:{'small': _vm.isSmall},attrs:{\"href\":_vm.allowPlay ? undefined : _vm.attachment.url},on:{\"click\":_vm.openModal}},[_c('VideoAttachment',{staticClass:\"video\",attrs:{\"attachment\":_vm.attachment,\"controls\":_vm.allowPlay}}),_vm._v(\" \"),(!_vm.allowPlay)?_c('i',{staticClass:\"play-icon icon-play-circled\"}):_vm._e()],1):_vm._e(),_vm._v(\" \"),(_vm.type === 'audio')?_c('audio',{attrs:{\"src\":_vm.attachment.url,\"controls\":\"\"}}):_vm._e(),_vm._v(\" \"),(_vm.type === 'html' && _vm.attachment.oembed)?_c('div',{staticClass:\"oembed\",on:{\"click\":function($event){$event.preventDefault();return _vm.linkClicked($event)}}},[(_vm.attachment.thumb_url)?_c('div',{staticClass:\"image\"},[_c('img',{attrs:{\"src\":_vm.attachment.thumb_url}})]):_vm._e(),_vm._v(\" \"),_c('div',{staticClass:\"text\"},[_c('h1',[_c('a',{attrs:{\"href\":_vm.attachment.url}},[_vm._v(_vm._s(_vm.attachment.oembed.title))])]),_vm._v(\" \"),_c('div',{domProps:{\"innerHTML\":_vm._s(_vm.attachment.oembed.oembedHTML)}})])]):_vm._e()])}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return (_vm.loggedIn)?_c('div',[_c('i',{staticClass:\"button-icon favorite-button fav-active\",class:_vm.classes,attrs:{\"title\":_vm.$t('tool_tip.favorite')},on:{\"click\":function($event){$event.preventDefault();_vm.favorite()}}}),_vm._v(\" \"),(!_vm.mergedConfig.hidePostStats && _vm.status.fave_num > 0)?_c('span',[_vm._v(_vm._s(_vm.status.fave_num))]):_vm._e()]):_c('div',[_c('i',{staticClass:\"button-icon favorite-button\",class:_vm.classes,attrs:{\"title\":_vm.$t('tool_tip.favorite')}}),_vm._v(\" \"),(!_vm.mergedConfig.hidePostStats && _vm.status.fave_num > 0)?_c('span',[_vm._v(_vm._s(_vm.status.fave_num))]):_vm._e()])}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return (_vm.loggedIn)?_c('div',[(_vm.visibility !== 'private' && _vm.visibility !== 'direct')?[_c('i',{staticClass:\"button-icon retweet-button icon-retweet rt-active\",class:_vm.classes,attrs:{\"title\":_vm.$t('tool_tip.repeat')},on:{\"click\":function($event){$event.preventDefault();_vm.retweet()}}}),_vm._v(\" \"),(!_vm.mergedConfig.hidePostStats && _vm.status.repeat_num > 0)?_c('span',[_vm._v(_vm._s(_vm.status.repeat_num))]):_vm._e()]:[_c('i',{staticClass:\"button-icon icon-lock\",class:_vm.classes,attrs:{\"title\":_vm.$t('timeline.no_retweet_hint')}})]],2):(!_vm.loggedIn)?_c('div',[_c('i',{staticClass:\"button-icon icon-retweet\",class:_vm.classes,attrs:{\"title\":_vm.$t('tool_tip.repeat')}}),_vm._v(\" \"),(!_vm.mergedConfig.hidePostStats && _vm.status.repeat_num > 0)?_c('span',[_vm._v(_vm._s(_vm.status.repeat_num))]):_vm._e()]):_vm._e()}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('time',{attrs:{\"datetime\":_vm.time,\"title\":_vm.localeDateString}},[_vm._v(\"\\n \"+_vm._s(_vm.$t(_vm.relativeTime.key, [_vm.relativeTime.num]))+\"\\n\")])}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:\"poll\",class:_vm.containerClass},[_vm._l((_vm.options),function(option,index){return _c('div',{key:index,staticClass:\"poll-option\"},[(_vm.showResults)?_c('div',{staticClass:\"option-result\",attrs:{\"title\":_vm.resultTitle(option)}},[_c('div',{staticClass:\"option-result-label\"},[_c('span',{staticClass:\"result-percentage\"},[_vm._v(\"\\n \"+_vm._s(_vm.percentageForOption(option.votes_count))+\"%\\n \")]),_vm._v(\" \"),_c('span',[_vm._v(_vm._s(option.title))])]),_vm._v(\" \"),_c('div',{staticClass:\"result-fill\",style:({ 'width': ((_vm.percentageForOption(option.votes_count)) + \"%\") })})]):_c('div',{on:{\"click\":function($event){_vm.activateOption(index)}}},[(_vm.poll.multiple)?_c('input',{attrs:{\"type\":\"checkbox\",\"disabled\":_vm.loading},domProps:{\"value\":index}}):_c('input',{attrs:{\"type\":\"radio\",\"disabled\":_vm.loading},domProps:{\"value\":index}}),_vm._v(\" \"),_c('label',{staticClass:\"option-vote\"},[_c('div',[_vm._v(_vm._s(option.title))])])])])}),_vm._v(\" \"),_c('div',{staticClass:\"footer faint\"},[(!_vm.showResults)?_c('button',{staticClass:\"btn btn-default poll-vote-button\",attrs:{\"type\":\"button\",\"disabled\":_vm.isDisabled},on:{\"click\":_vm.vote}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('polls.vote'))+\"\\n \")]):_vm._e(),_vm._v(\" \"),_c('div',{staticClass:\"total\"},[_vm._v(\"\\n \"+_vm._s(_vm.totalVotesCount)+\" \"+_vm._s(_vm.$t(\"polls.votes\"))+\" · \\n \")]),_vm._v(\" \"),_c('i18n',{attrs:{\"path\":_vm.expired ? 'polls.expired' : 'polls.expires_in'}},[_c('Timeago',{attrs:{\"time\":_vm.expiresAt,\"auto-update\":60,\"now-threshold\":0}})],1)],1)],2)}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return (_vm.canDelete || _vm.canMute || _vm.canPin)?_c('v-popover',{staticClass:\"extra-button-popover\",attrs:{\"trigger\":\"click\",\"placement\":\"top\"}},[_c('div',{attrs:{\"slot\":\"popover\"},slot:\"popover\"},[_c('div',{staticClass:\"dropdown-menu\"},[(_vm.canMute && !_vm.status.thread_muted)?_c('button',{staticClass:\"dropdown-item dropdown-item-icon\",on:{\"click\":function($event){$event.preventDefault();return _vm.muteConversation($event)}}},[_c('i',{staticClass:\"icon-eye-off\"}),_c('span',[_vm._v(_vm._s(_vm.$t(\"status.mute_conversation\")))])]):_vm._e(),_vm._v(\" \"),(_vm.canMute && _vm.status.thread_muted)?_c('button',{staticClass:\"dropdown-item dropdown-item-icon\",on:{\"click\":function($event){$event.preventDefault();return _vm.unmuteConversation($event)}}},[_c('i',{staticClass:\"icon-eye-off\"}),_c('span',[_vm._v(_vm._s(_vm.$t(\"status.unmute_conversation\")))])]):_vm._e(),_vm._v(\" \"),(!_vm.status.pinned && _vm.canPin)?_c('button',{directives:[{name:\"close-popover\",rawName:\"v-close-popover\"}],staticClass:\"dropdown-item dropdown-item-icon\",on:{\"click\":function($event){$event.preventDefault();return _vm.pinStatus($event)}}},[_c('i',{staticClass:\"icon-pin\"}),_c('span',[_vm._v(_vm._s(_vm.$t(\"status.pin\")))])]):_vm._e(),_vm._v(\" \"),(_vm.status.pinned && _vm.canPin)?_c('button',{directives:[{name:\"close-popover\",rawName:\"v-close-popover\"}],staticClass:\"dropdown-item dropdown-item-icon\",on:{\"click\":function($event){$event.preventDefault();return _vm.unpinStatus($event)}}},[_c('i',{staticClass:\"icon-pin\"}),_c('span',[_vm._v(_vm._s(_vm.$t(\"status.unpin\")))])]):_vm._e(),_vm._v(\" \"),(_vm.canDelete)?_c('button',{directives:[{name:\"close-popover\",rawName:\"v-close-popover\"}],staticClass:\"dropdown-item dropdown-item-icon\",on:{\"click\":function($event){$event.preventDefault();return _vm.deleteStatus($event)}}},[_c('i',{staticClass:\"icon-cancel\"}),_c('span',[_vm._v(_vm._s(_vm.$t(\"status.delete\")))])]):_vm._e()])]),_vm._v(\" \"),_c('div',{staticClass:\"button-icon\"},[_c('i',{staticClass:\"icon-ellipsis\"})])]):_vm._e()}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:\"media-upload\",on:{\"drop\":[function($event){$event.preventDefault();},_vm.fileDrop],\"dragover\":function($event){$event.preventDefault();return _vm.fileDrag($event)}}},[_c('label',{staticClass:\"btn btn-default\",attrs:{\"title\":_vm.$t('tool_tip.media_upload')}},[(_vm.uploading)?_c('i',{staticClass:\"icon-spin4 animate-spin\"}):_vm._e(),_vm._v(\" \"),(!_vm.uploading)?_c('i',{staticClass:\"icon-upload\"}):_vm._e(),_vm._v(\" \"),(_vm.uploadReady)?_c('input',{staticStyle:{\"position\":\"fixed\",\"top\":\"-100em\"},attrs:{\"type\":\"file\",\"multiple\":\"true\"},on:{\"change\":_vm.change}}):_vm._e()])])}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return (!_vm.showNothing)?_c('div',{staticClass:\"scope-selector\"},[(_vm.showDirect)?_c('i',{staticClass:\"icon-mail-alt\",class:_vm.css.direct,attrs:{\"title\":_vm.$t('post_status.scope.direct')},on:{\"click\":function($event){_vm.changeVis('direct')}}}):_vm._e(),_vm._v(\" \"),(_vm.showPrivate)?_c('i',{staticClass:\"icon-lock\",class:_vm.css.private,attrs:{\"title\":_vm.$t('post_status.scope.private')},on:{\"click\":function($event){_vm.changeVis('private')}}}):_vm._e(),_vm._v(\" \"),(_vm.showUnlisted)?_c('i',{staticClass:\"icon-lock-open-alt\",class:_vm.css.unlisted,attrs:{\"title\":_vm.$t('post_status.scope.unlisted')},on:{\"click\":function($event){_vm.changeVis('unlisted')}}}):_vm._e(),_vm._v(\" \"),(_vm.showPublic)?_c('i',{staticClass:\"icon-globe\",class:_vm.css.public,attrs:{\"title\":_vm.$t('post_status.scope.public')},on:{\"click\":function($event){_vm.changeVis('public')}}}):_vm._e()]):_vm._e()}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('label',{staticClass:\"checkbox\",class:{ disabled: _vm.disabled, indeterminate: _vm.indeterminate }},[_c('input',{attrs:{\"type\":\"checkbox\",\"disabled\":_vm.disabled},domProps:{\"checked\":_vm.checked,\"indeterminate\":_vm.indeterminate},on:{\"change\":function($event){_vm.$emit('change', $event.target.checked)}}}),_vm._v(\" \"),_c('i',{staticClass:\"checkbox-indicator\"}),_vm._v(\" \"),(!!_vm.$slots.default)?_c('span',{staticClass:\"label\"},[_vm._t(\"default\")],2):_vm._e()])}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:\"emoji-picker panel panel-default panel-body\"},[_c('div',{staticClass:\"heading\"},[_c('span',{staticClass:\"emoji-tabs\"},_vm._l((_vm.emojis),function(group){return _c('span',{key:group.id,staticClass:\"emoji-tabs-item\",class:{\n active: _vm.activeGroupView === group.id,\n disabled: group.emojis.length === 0\n },attrs:{\"title\":group.text},on:{\"click\":function($event){$event.preventDefault();_vm.highlight(group.id)}}},[_c('i',{class:group.icon})])}),0),_vm._v(\" \"),(_vm.stickerPickerEnabled)?_c('span',{staticClass:\"additional-tabs\"},[_c('span',{staticClass:\"stickers-tab-icon additional-tabs-item\",class:{active: _vm.showingStickers},attrs:{\"title\":_vm.$t('emoji.stickers')},on:{\"click\":function($event){$event.preventDefault();return _vm.toggleStickers($event)}}},[_c('i',{staticClass:\"icon-star\"})])]):_vm._e()]),_vm._v(\" \"),_c('div',{staticClass:\"content\"},[_c('div',{staticClass:\"emoji-content\",class:{hidden: _vm.showingStickers}},[_c('div',{staticClass:\"emoji-search\"},[_c('input',{directives:[{name:\"model\",rawName:\"v-model\",value:(_vm.keyword),expression:\"keyword\"}],staticClass:\"form-control\",attrs:{\"type\":\"text\",\"placeholder\":_vm.$t('emoji.search_emoji')},domProps:{\"value\":(_vm.keyword)},on:{\"input\":function($event){if($event.target.composing){ return; }_vm.keyword=$event.target.value}}})]),_vm._v(\" \"),_c('div',{ref:\"emoji-groups\",staticClass:\"emoji-groups\",class:_vm.groupsScrolledClass,on:{\"scroll\":_vm.onScroll}},_vm._l((_vm.emojisView),function(group){return _c('div',{key:group.id,staticClass:\"emoji-group\"},[_c('h6',{ref:'group-' + group.id,refInFor:true,staticClass:\"emoji-group-title\"},[_vm._v(\"\\n \"+_vm._s(group.text)+\"\\n \")]),_vm._v(\" \"),_vm._l((group.emojis),function(emoji){return _c('span',{key:group.id + emoji.displayText,staticClass:\"emoji-item\",attrs:{\"title\":emoji.displayText},on:{\"click\":function($event){$event.stopPropagation();$event.preventDefault();_vm.onEmoji(emoji)}}},[(!emoji.imageUrl)?_c('span',[_vm._v(_vm._s(emoji.replacement))]):_c('img',{attrs:{\"src\":emoji.imageUrl}})])}),_vm._v(\" \"),_c('span',{ref:'group-end-' + group.id,refInFor:true})],2)}),0),_vm._v(\" \"),_c('div',{staticClass:\"keep-open\"},[_c('Checkbox',{model:{value:(_vm.keepOpen),callback:function ($$v) {_vm.keepOpen=$$v},expression:\"keepOpen\"}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('emoji.keep_open'))+\"\\n \")])],1)]),_vm._v(\" \"),(_vm.showingStickers)?_c('div',{staticClass:\"stickers-content\"},[_c('sticker-picker',{on:{\"uploaded\":_vm.onStickerUploaded,\"upload-failed\":_vm.onStickerUploadFailed}})],1):_vm._e()])])}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{directives:[{name:\"click-outside\",rawName:\"v-click-outside\",value:(_vm.onClickOutside),expression:\"onClickOutside\"}],staticClass:\"emoji-input\",class:{ 'with-picker': !_vm.hideEmojiButton }},[_vm._t(\"default\"),_vm._v(\" \"),(_vm.enableEmojiPicker)?[(!_vm.hideEmojiButton)?_c('div',{staticClass:\"emoji-picker-icon\",on:{\"click\":function($event){$event.preventDefault();return _vm.togglePicker($event)}}},[_c('i',{staticClass:\"icon-smile\"})]):_vm._e(),_vm._v(\" \"),(_vm.enableEmojiPicker)?_c('EmojiPicker',{ref:\"picker\",staticClass:\"emoji-picker-panel\",class:{ hide: !_vm.showPicker },attrs:{\"enable-sticker-picker\":_vm.enableStickerPicker},on:{\"emoji\":_vm.insert,\"sticker-uploaded\":_vm.onStickerUploaded,\"sticker-upload-failed\":_vm.onStickerUploadFailed}}):_vm._e()]:_vm._e(),_vm._v(\" \"),_c('div',{ref:\"panel\",staticClass:\"autocomplete-panel\",class:{ hide: !_vm.showSuggestions }},[_c('div',{staticClass:\"autocomplete-panel-body\"},_vm._l((_vm.suggestions),function(suggestion,index){return _c('div',{key:index,staticClass:\"autocomplete-item\",class:{ highlighted: suggestion.highlighted },on:{\"click\":function($event){$event.stopPropagation();$event.preventDefault();_vm.onClick($event, suggestion)}}},[_c('span',{staticClass:\"image\"},[(suggestion.img)?_c('img',{attrs:{\"src\":suggestion.img}}):_c('span',[_vm._v(_vm._s(suggestion.replacement))])]),_vm._v(\" \"),_c('div',{staticClass:\"label\"},[_c('span',{staticClass:\"displayText\"},[_vm._v(_vm._s(suggestion.displayText))]),_vm._v(\" \"),_c('span',{staticClass:\"detailText\"},[_vm._v(_vm._s(suggestion.detailText))])])])}),0)])],2)}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return (_vm.visible)?_c('div',{staticClass:\"poll-form\"},[_vm._l((_vm.options),function(option,index){return _c('div',{key:index,staticClass:\"poll-option\"},[_c('div',{staticClass:\"input-container\"},[_c('input',{directives:[{name:\"model\",rawName:\"v-model\",value:(_vm.options[index]),expression:\"options[index]\"}],staticClass:\"poll-option-input\",attrs:{\"id\":(\"poll-\" + index),\"type\":\"text\",\"placeholder\":_vm.$t('polls.option'),\"maxlength\":_vm.maxLength},domProps:{\"value\":(_vm.options[index])},on:{\"change\":_vm.updatePollToParent,\"keydown\":function($event){if(!('button' in $event)&&_vm._k($event.keyCode,\"enter\",13,$event.key,\"Enter\")){ return null; }$event.stopPropagation();$event.preventDefault();_vm.nextOption(index)},\"input\":function($event){if($event.target.composing){ return; }_vm.$set(_vm.options, index, $event.target.value)}}})]),_vm._v(\" \"),(_vm.options.length > 2)?_c('div',{staticClass:\"icon-container\"},[_c('i',{staticClass:\"icon-cancel\",on:{\"click\":function($event){_vm.deleteOption(index)}}})]):_vm._e()])}),_vm._v(\" \"),(_vm.options.length < _vm.maxOptions)?_c('a',{staticClass:\"add-option faint\",on:{\"click\":_vm.addOption}},[_c('i',{staticClass:\"icon-plus\"}),_vm._v(\"\\n \"+_vm._s(_vm.$t(\"polls.add_option\"))+\"\\n \")]):_vm._e(),_vm._v(\" \"),_c('div',{staticClass:\"poll-type-expiry\"},[_c('div',{staticClass:\"poll-type\",attrs:{\"title\":_vm.$t('polls.type')}},[_c('label',{staticClass:\"select\",attrs:{\"for\":\"poll-type-selector\"}},[_c('select',{directives:[{name:\"model\",rawName:\"v-model\",value:(_vm.pollType),expression:\"pollType\"}],staticClass:\"select\",on:{\"change\":[function($event){var $$selectedVal = Array.prototype.filter.call($event.target.options,function(o){return o.selected}).map(function(o){var val = \"_value\" in o ? o._value : o.value;return val}); _vm.pollType=$event.target.multiple ? $$selectedVal : $$selectedVal[0]},_vm.updatePollToParent]}},[_c('option',{attrs:{\"value\":\"single\"}},[_vm._v(_vm._s(_vm.$t('polls.single_choice')))]),_vm._v(\" \"),_c('option',{attrs:{\"value\":\"multiple\"}},[_vm._v(_vm._s(_vm.$t('polls.multiple_choices')))])]),_vm._v(\" \"),_c('i',{staticClass:\"icon-down-open\"})])]),_vm._v(\" \"),_c('div',{staticClass:\"poll-expiry\",attrs:{\"title\":_vm.$t('polls.expiry')}},[_c('input',{directives:[{name:\"model\",rawName:\"v-model\",value:(_vm.expiryAmount),expression:\"expiryAmount\"}],staticClass:\"expiry-amount hide-number-spinner\",attrs:{\"type\":\"number\",\"min\":_vm.minExpirationInCurrentUnit,\"max\":_vm.maxExpirationInCurrentUnit},domProps:{\"value\":(_vm.expiryAmount)},on:{\"change\":_vm.expiryAmountChange,\"input\":function($event){if($event.target.composing){ return; }_vm.expiryAmount=$event.target.value}}}),_vm._v(\" \"),_c('label',{staticClass:\"expiry-unit select\"},[_c('select',{directives:[{name:\"model\",rawName:\"v-model\",value:(_vm.expiryUnit),expression:\"expiryUnit\"}],on:{\"change\":[function($event){var $$selectedVal = Array.prototype.filter.call($event.target.options,function(o){return o.selected}).map(function(o){var val = \"_value\" in o ? o._value : o.value;return val}); _vm.expiryUnit=$event.target.multiple ? $$selectedVal : $$selectedVal[0]},_vm.expiryAmountChange]}},_vm._l((_vm.expiryUnits),function(unit){return _c('option',{key:unit,domProps:{\"value\":unit}},[_vm._v(\"\\n \"+_vm._s(_vm.$t((\"time.\" + unit + \"_short\"), ['']))+\"\\n \")])}),0),_vm._v(\" \"),_c('i',{staticClass:\"icon-down-open\"})])])])],2):_vm._e()}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{ref:\"form\",staticClass:\"post-status-form\"},[_c('form',{attrs:{\"autocomplete\":\"off\"},on:{\"submit\":function($event){$event.preventDefault();_vm.postStatus(_vm.newStatus)}}},[_c('div',{staticClass:\"form-group\"},[(!_vm.$store.state.users.currentUser.locked && _vm.newStatus.visibility == 'private')?_c('i18n',{staticClass:\"visibility-notice\",attrs:{\"path\":\"post_status.account_not_locked_warning\",\"tag\":\"p\"}},[_c('router-link',{attrs:{\"to\":{ name: 'user-settings' }}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('post_status.account_not_locked_warning_link'))+\"\\n \")])],1):_vm._e(),_vm._v(\" \"),(!_vm.hideScopeNotice && _vm.newStatus.visibility === 'public')?_c('p',{staticClass:\"visibility-notice notice-dismissible\"},[_c('span',[_vm._v(_vm._s(_vm.$t('post_status.scope_notice.public')))]),_vm._v(\" \"),_c('a',{staticClass:\"button-icon dismiss\",on:{\"click\":function($event){$event.preventDefault();_vm.dismissScopeNotice()}}},[_c('i',{staticClass:\"icon-cancel\"})])]):(!_vm.hideScopeNotice && _vm.newStatus.visibility === 'unlisted')?_c('p',{staticClass:\"visibility-notice notice-dismissible\"},[_c('span',[_vm._v(_vm._s(_vm.$t('post_status.scope_notice.unlisted')))]),_vm._v(\" \"),_c('a',{staticClass:\"button-icon dismiss\",on:{\"click\":function($event){$event.preventDefault();_vm.dismissScopeNotice()}}},[_c('i',{staticClass:\"icon-cancel\"})])]):(!_vm.hideScopeNotice && _vm.newStatus.visibility === 'private' && _vm.$store.state.users.currentUser.locked)?_c('p',{staticClass:\"visibility-notice notice-dismissible\"},[_c('span',[_vm._v(_vm._s(_vm.$t('post_status.scope_notice.private')))]),_vm._v(\" \"),_c('a',{staticClass:\"button-icon dismiss\",on:{\"click\":function($event){$event.preventDefault();_vm.dismissScopeNotice()}}},[_c('i',{staticClass:\"icon-cancel\"})])]):(_vm.newStatus.visibility === 'direct')?_c('p',{staticClass:\"visibility-notice\"},[(_vm.safeDMEnabled)?_c('span',[_vm._v(_vm._s(_vm.$t('post_status.direct_warning_to_first_only')))]):_c('span',[_vm._v(_vm._s(_vm.$t('post_status.direct_warning_to_all')))])]):_vm._e(),_vm._v(\" \"),(_vm.newStatus.spoilerText || _vm.alwaysShowSubject)?_c('EmojiInput',{staticClass:\"form-control\",attrs:{\"enable-emoji-picker\":\"\",\"suggest\":_vm.emojiSuggestor},model:{value:(_vm.newStatus.spoilerText),callback:function ($$v) {_vm.$set(_vm.newStatus, \"spoilerText\", $$v)},expression:\"newStatus.spoilerText\"}},[_c('input',{directives:[{name:\"model\",rawName:\"v-model\",value:(_vm.newStatus.spoilerText),expression:\"newStatus.spoilerText\"}],staticClass:\"form-post-subject\",attrs:{\"type\":\"text\",\"placeholder\":_vm.$t('post_status.content_warning')},domProps:{\"value\":(_vm.newStatus.spoilerText)},on:{\"input\":function($event){if($event.target.composing){ return; }_vm.$set(_vm.newStatus, \"spoilerText\", $event.target.value)}}})]):_vm._e(),_vm._v(\" \"),_c('EmojiInput',{ref:\"emoji-input\",staticClass:\"form-control main-input\",attrs:{\"suggest\":_vm.emojiUserSuggestor,\"enable-emoji-picker\":\"\",\"hide-emoji-button\":\"\",\"enable-sticker-picker\":\"\"},on:{\"input\":_vm.onEmojiInputInput,\"sticker-uploaded\":_vm.addMediaFile,\"sticker-upload-failed\":_vm.uploadFailed},model:{value:(_vm.newStatus.status),callback:function ($$v) {_vm.$set(_vm.newStatus, \"status\", $$v)},expression:\"newStatus.status\"}},[_c('textarea',{directives:[{name:\"model\",rawName:\"v-model\",value:(_vm.newStatus.status),expression:\"newStatus.status\"}],ref:\"textarea\",staticClass:\"form-post-body\",attrs:{\"placeholder\":_vm.$t('post_status.default'),\"rows\":\"1\",\"disabled\":_vm.posting},domProps:{\"value\":(_vm.newStatus.status)},on:{\"keydown\":function($event){if(!('button' in $event)&&_vm._k($event.keyCode,\"enter\",13,$event.key,\"Enter\")){ return null; }if(!$event.metaKey){ return null; }_vm.postStatus(_vm.newStatus)},\"keyup\":function($event){if(!('button' in $event)&&_vm._k($event.keyCode,\"enter\",13,$event.key,\"Enter\")){ return null; }if(!$event.ctrlKey){ return null; }_vm.postStatus(_vm.newStatus)},\"drop\":_vm.fileDrop,\"dragover\":function($event){$event.preventDefault();return _vm.fileDrag($event)},\"input\":[function($event){if($event.target.composing){ return; }_vm.$set(_vm.newStatus, \"status\", $event.target.value)},_vm.resize],\"compositionupdate\":_vm.resize,\"paste\":_vm.paste}}),_vm._v(\" \"),(_vm.hasStatusLengthLimit)?_c('p',{staticClass:\"character-counter faint\",class:{ error: _vm.isOverLengthLimit }},[_vm._v(\"\\n \"+_vm._s(_vm.charactersLeft)+\"\\n \")]):_vm._e()]),_vm._v(\" \"),_c('div',{staticClass:\"visibility-tray\"},[_c('scope-selector',{attrs:{\"show-all\":_vm.showAllScopes,\"user-default\":_vm.userDefaultScope,\"original-scope\":_vm.copyMessageScope,\"initial-scope\":_vm.newStatus.visibility,\"on-scope-change\":_vm.changeVis}}),_vm._v(\" \"),(_vm.postFormats.length > 1)?_c('div',{staticClass:\"text-format\"},[_c('label',{staticClass:\"select\",attrs:{\"for\":\"post-content-type\"}},[_c('select',{directives:[{name:\"model\",rawName:\"v-model\",value:(_vm.newStatus.contentType),expression:\"newStatus.contentType\"}],staticClass:\"form-control\",attrs:{\"id\":\"post-content-type\"},on:{\"change\":function($event){var $$selectedVal = Array.prototype.filter.call($event.target.options,function(o){return o.selected}).map(function(o){var val = \"_value\" in o ? o._value : o.value;return val}); _vm.$set(_vm.newStatus, \"contentType\", $event.target.multiple ? $$selectedVal : $$selectedVal[0])}}},_vm._l((_vm.postFormats),function(postFormat){return _c('option',{key:postFormat,domProps:{\"value\":postFormat}},[_vm._v(\"\\n \"+_vm._s(_vm.$t((\"post_status.content_type[\\\"\" + postFormat + \"\\\"]\")))+\"\\n \")])}),0),_vm._v(\" \"),_c('i',{staticClass:\"icon-down-open\"})])]):_vm._e(),_vm._v(\" \"),(_vm.postFormats.length === 1 && _vm.postFormats[0] !== 'text/plain')?_c('div',{staticClass:\"text-format\"},[_c('span',{staticClass:\"only-format\"},[_vm._v(\"\\n \"+_vm._s(_vm.$t((\"post_status.content_type[\\\"\" + (_vm.postFormats[0]) + \"\\\"]\")))+\"\\n \")])]):_vm._e()],1)],1),_vm._v(\" \"),(_vm.pollsAvailable)?_c('poll-form',{ref:\"pollForm\",attrs:{\"visible\":_vm.pollFormVisible},on:{\"update-poll\":_vm.setPoll}}):_vm._e(),_vm._v(\" \"),_c('div',{ref:\"bottom\",staticClass:\"form-bottom\"},[_c('div',{staticClass:\"form-bottom-left\"},[_c('media-upload',{ref:\"mediaUpload\",staticClass:\"media-upload-icon\",attrs:{\"drop-files\":_vm.dropFiles},on:{\"uploading\":_vm.disableSubmit,\"uploaded\":_vm.addMediaFile,\"upload-failed\":_vm.uploadFailed}}),_vm._v(\" \"),_c('div',{staticClass:\"emoji-icon\"},[_c('i',{staticClass:\"icon-smile btn btn-default\",attrs:{\"title\":_vm.$t('emoji.add_emoji')},on:{\"click\":_vm.showEmojiPicker}})]),_vm._v(\" \"),(_vm.pollsAvailable)?_c('div',{staticClass:\"poll-icon\",class:{ selected: _vm.pollFormVisible }},[_c('i',{staticClass:\"icon-chart-bar btn btn-default\",attrs:{\"title\":_vm.$t('polls.add_poll')},on:{\"click\":_vm.togglePollForm}})]):_vm._e()],1),_vm._v(\" \"),(_vm.posting)?_c('button',{staticClass:\"btn btn-default\",attrs:{\"disabled\":\"\"}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('post_status.posting'))+\"\\n \")]):(_vm.isOverLengthLimit)?_c('button',{staticClass:\"btn btn-default\",attrs:{\"disabled\":\"\"}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('general.submit'))+\"\\n \")]):_c('button',{staticClass:\"btn btn-default\",attrs:{\"disabled\":_vm.submitDisabled,\"type\":\"submit\"}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('general.submit'))+\"\\n \")])]),_vm._v(\" \"),(_vm.error)?_c('div',{staticClass:\"alert error\"},[_vm._v(\"\\n Error: \"+_vm._s(_vm.error)+\"\\n \"),_c('i',{staticClass:\"button-icon icon-cancel\",on:{\"click\":_vm.clearError}})]):_vm._e(),_vm._v(\" \"),_c('div',{staticClass:\"attachments\"},_vm._l((_vm.newStatus.files),function(file){return _c('div',{key:file.url,staticClass:\"media-upload-wrapper\"},[_c('i',{staticClass:\"fa button-icon icon-cancel\",on:{\"click\":function($event){_vm.removeMediaFile(file)}}}),_vm._v(\" \"),_c('div',{staticClass:\"media-upload-container attachment\"},[(_vm.type(file) === 'image')?_c('img',{staticClass:\"thumbnail media-upload\",attrs:{\"src\":file.url}}):_vm._e(),_vm._v(\" \"),(_vm.type(file) === 'video')?_c('video',{attrs:{\"src\":file.url,\"controls\":\"\"}}):_vm._e(),_vm._v(\" \"),(_vm.type(file) === 'audio')?_c('audio',{attrs:{\"src\":file.url,\"controls\":\"\"}}):_vm._e(),_vm._v(\" \"),(_vm.type(file) === 'unknown')?_c('a',{attrs:{\"href\":file.url}},[_vm._v(_vm._s(file.url))]):_vm._e()])])}),0),_vm._v(\" \"),(_vm.newStatus.files.length > 0)?_c('div',{staticClass:\"upload_settings\"},[_c('Checkbox',{model:{value:(_vm.newStatus.nsfw),callback:function ($$v) {_vm.$set(_vm.newStatus, \"nsfw\", $$v)},expression:\"newStatus.nsfw\"}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('post_status.attachments_sensitive'))+\"\\n \")])],1):_vm._e()],1)])}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('StillImage',{staticClass:\"avatar\",class:{ 'avatar-compact': _vm.compact, 'better-shadow': _vm.betterShadow },attrs:{\"alt\":_vm.user.screen_name,\"title\":_vm.user.screen_name,\"src\":_vm.imgSrc,\"image-load-error\":_vm.imageLoadError}})}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:\"remote-follow\"},[_c('form',{attrs:{\"method\":\"POST\",\"action\":_vm.subscribeUrl}},[_c('input',{attrs:{\"type\":\"hidden\",\"name\":\"nickname\"},domProps:{\"value\":_vm.user.screen_name}}),_vm._v(\" \"),_c('input',{attrs:{\"type\":\"hidden\",\"name\":\"profile\",\"value\":\"\"}}),_vm._v(\" \"),_c('button',{staticClass:\"remote-button\",attrs:{\"click\":\"submit\"}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('user_card.remote_follow'))+\"\\n \")])])])}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('button',{attrs:{\"disabled\":_vm.progress || _vm.disabled},on:{\"click\":_vm.onClick}},[(_vm.progress && _vm.$slots.progress)?[_vm._t(\"progress\")]:[_vm._t(\"default\")]],2)}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('button',{staticClass:\"btn btn-default follow-button\",class:{ pressed: _vm.isPressed },attrs:{\"disabled\":_vm.inProgress,\"title\":_vm.title},on:{\"click\":_vm.onClick}},[_vm._v(\"\\n \"+_vm._s(_vm.label)+\"\\n\")])}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('span',{class:{ 'dark-overlay': _vm.darkOverlay },on:{\"click\":function($event){if($event.target !== $event.currentTarget){ return null; }$event.stopPropagation();_vm.onCancel()}}},[_c('div',{staticClass:\"dialog-modal panel panel-default\",on:{\"click\":function($event){$event.stopPropagation();}}},[_c('div',{staticClass:\"panel-heading dialog-modal-heading\"},[_c('div',{staticClass:\"title\"},[_vm._t(\"header\")],2)]),_vm._v(\" \"),_c('div',{staticClass:\"dialog-modal-content\"},[_vm._t(\"default\")],2),_vm._v(\" \"),_c('div',{staticClass:\"dialog-modal-footer user-interactions panel-footer\"},[_vm._t(\"footer\")],2)])])}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',[_c('v-popover',{staticClass:\"moderation-tools-popover\",attrs:{\"trigger\":\"click\",\"placement\":\"bottom-end\"},on:{\"show\":function($event){_vm.showDropDown = true},\"hide\":function($event){_vm.showDropDown = false}}},[_c('div',{attrs:{\"slot\":\"popover\"},slot:\"popover\"},[_c('div',{staticClass:\"dropdown-menu\"},[(_vm.user.is_local)?_c('span',[_c('button',{staticClass:\"dropdown-item\",on:{\"click\":function($event){_vm.toggleRight(\"admin\")}}},[_vm._v(\"\\n \"+_vm._s(_vm.$t(!!_vm.user.rights.admin ? 'user_card.admin_menu.revoke_admin' : 'user_card.admin_menu.grant_admin'))+\"\\n \")]),_vm._v(\" \"),_c('button',{staticClass:\"dropdown-item\",on:{\"click\":function($event){_vm.toggleRight(\"moderator\")}}},[_vm._v(\"\\n \"+_vm._s(_vm.$t(!!_vm.user.rights.moderator ? 'user_card.admin_menu.revoke_moderator' : 'user_card.admin_menu.grant_moderator'))+\"\\n \")]),_vm._v(\" \"),_c('div',{staticClass:\"dropdown-divider\",attrs:{\"role\":\"separator\"}})]):_vm._e(),_vm._v(\" \"),_c('button',{staticClass:\"dropdown-item\",on:{\"click\":function($event){_vm.toggleActivationStatus()}}},[_vm._v(\"\\n \"+_vm._s(_vm.$t(!!_vm.user.deactivated ? 'user_card.admin_menu.activate_account' : 'user_card.admin_menu.deactivate_account'))+\"\\n \")]),_vm._v(\" \"),_c('button',{staticClass:\"dropdown-item\",on:{\"click\":function($event){_vm.deleteUserDialog(true)}}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('user_card.admin_menu.delete_account'))+\"\\n \")]),_vm._v(\" \"),(_vm.hasTagPolicy)?_c('div',{staticClass:\"dropdown-divider\",attrs:{\"role\":\"separator\"}}):_vm._e(),_vm._v(\" \"),(_vm.hasTagPolicy)?_c('span',[_c('button',{staticClass:\"dropdown-item\",on:{\"click\":function($event){_vm.toggleTag(_vm.tags.FORCE_NSFW)}}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('user_card.admin_menu.force_nsfw'))+\"\\n \"),_c('span',{staticClass:\"menu-checkbox\",class:{ 'menu-checkbox-checked': _vm.hasTag(_vm.tags.FORCE_NSFW) }})]),_vm._v(\" \"),_c('button',{staticClass:\"dropdown-item\",on:{\"click\":function($event){_vm.toggleTag(_vm.tags.STRIP_MEDIA)}}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('user_card.admin_menu.strip_media'))+\"\\n \"),_c('span',{staticClass:\"menu-checkbox\",class:{ 'menu-checkbox-checked': _vm.hasTag(_vm.tags.STRIP_MEDIA) }})]),_vm._v(\" \"),_c('button',{staticClass:\"dropdown-item\",on:{\"click\":function($event){_vm.toggleTag(_vm.tags.FORCE_UNLISTED)}}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('user_card.admin_menu.force_unlisted'))+\"\\n \"),_c('span',{staticClass:\"menu-checkbox\",class:{ 'menu-checkbox-checked': _vm.hasTag(_vm.tags.FORCE_UNLISTED) }})]),_vm._v(\" \"),_c('button',{staticClass:\"dropdown-item\",on:{\"click\":function($event){_vm.toggleTag(_vm.tags.SANDBOX)}}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('user_card.admin_menu.sandbox'))+\"\\n \"),_c('span',{staticClass:\"menu-checkbox\",class:{ 'menu-checkbox-checked': _vm.hasTag(_vm.tags.SANDBOX) }})]),_vm._v(\" \"),(_vm.user.is_local)?_c('button',{staticClass:\"dropdown-item\",on:{\"click\":function($event){_vm.toggleTag(_vm.tags.DISABLE_REMOTE_SUBSCRIPTION)}}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('user_card.admin_menu.disable_remote_subscription'))+\"\\n \"),_c('span',{staticClass:\"menu-checkbox\",class:{ 'menu-checkbox-checked': _vm.hasTag(_vm.tags.DISABLE_REMOTE_SUBSCRIPTION) }})]):_vm._e(),_vm._v(\" \"),(_vm.user.is_local)?_c('button',{staticClass:\"dropdown-item\",on:{\"click\":function($event){_vm.toggleTag(_vm.tags.DISABLE_ANY_SUBSCRIPTION)}}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('user_card.admin_menu.disable_any_subscription'))+\"\\n \"),_c('span',{staticClass:\"menu-checkbox\",class:{ 'menu-checkbox-checked': _vm.hasTag(_vm.tags.DISABLE_ANY_SUBSCRIPTION) }})]):_vm._e(),_vm._v(\" \"),(_vm.user.is_local)?_c('button',{staticClass:\"dropdown-item\",on:{\"click\":function($event){_vm.toggleTag(_vm.tags.QUARANTINE)}}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('user_card.admin_menu.quarantine'))+\"\\n \"),_c('span',{staticClass:\"menu-checkbox\",class:{ 'menu-checkbox-checked': _vm.hasTag(_vm.tags.QUARANTINE) }})]):_vm._e()]):_vm._e()])]),_vm._v(\" \"),_c('button',{staticClass:\"btn btn-default btn-block\",class:{ pressed: _vm.showDropDown }},[_vm._v(\"\\n \"+_vm._s(_vm.$t('user_card.admin_menu.moderation'))+\"\\n \")])]),_vm._v(\" \"),_c('portal',{attrs:{\"to\":\"modal\"}},[(_vm.showDeleteUserDialog)?_c('DialogModal',{attrs:{\"on-cancel\":_vm.deleteUserDialog.bind(this, false)}},[_c('template',{slot:\"header\"},[_vm._v(\"\\n \"+_vm._s(_vm.$t('user_card.admin_menu.delete_user'))+\"\\n \")]),_vm._v(\" \"),_c('p',[_vm._v(_vm._s(_vm.$t('user_card.admin_menu.delete_user_confirmation')))]),_vm._v(\" \"),_c('template',{slot:\"footer\"},[_c('button',{staticClass:\"btn btn-default\",on:{\"click\":function($event){_vm.deleteUserDialog(false)}}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('general.cancel'))+\"\\n \")]),_vm._v(\" \"),_c('button',{staticClass:\"btn btn-default danger\",on:{\"click\":function($event){_vm.deleteUser()}}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('user_card.admin_menu.delete_user'))+\"\\n \")])])],2):_vm._e()],1)],1)}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:\"account-actions\"},[_c('v-popover',{staticClass:\"account-tools-popover\",attrs:{\"trigger\":\"click\",\"container\":false,\"placement\":\"bottom-end\",\"offset\":5}},[_c('div',{attrs:{\"slot\":\"popover\"},slot:\"popover\"},[_c('div',{staticClass:\"dropdown-menu\"},[_c('button',{staticClass:\"btn btn-default btn-block dropdown-item\",on:{\"click\":_vm.mentionUser}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('user_card.mention'))+\"\\n \")]),_vm._v(\" \"),(_vm.user.following)?[_c('div',{staticClass:\"dropdown-divider\",attrs:{\"role\":\"separator\"}}),_vm._v(\" \"),(_vm.user.showing_reblogs)?_c('button',{staticClass:\"btn btn-default dropdown-item\",on:{\"click\":_vm.hideRepeats}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('user_card.hide_repeats'))+\"\\n \")]):_vm._e(),_vm._v(\" \"),(!_vm.user.showing_reblogs)?_c('button',{staticClass:\"btn btn-default dropdown-item\",on:{\"click\":_vm.showRepeats}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('user_card.show_repeats'))+\"\\n \")]):_vm._e()]:_vm._e(),_vm._v(\" \"),_c('div',{staticClass:\"dropdown-divider\",attrs:{\"role\":\"separator\"}}),_vm._v(\" \"),(_vm.user.statusnet_blocking)?_c('button',{staticClass:\"btn btn-default btn-block dropdown-item\",on:{\"click\":_vm.unblockUser}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('user_card.unblock'))+\"\\n \")]):_c('button',{staticClass:\"btn btn-default btn-block dropdown-item\",on:{\"click\":_vm.blockUser}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('user_card.block'))+\"\\n \")]),_vm._v(\" \"),_c('button',{staticClass:\"btn btn-default btn-block dropdown-item\",on:{\"click\":_vm.reportUser}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('user_card.report'))+\"\\n \")])],2)]),_vm._v(\" \"),_c('div',{staticClass:\"btn btn-default ellipsis-button\"},[_c('i',{staticClass:\"icon-ellipsis trigger-button\"})])])],1)}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:\"user-card\",class:_vm.classes},[_c('div',{staticClass:\"background-image\",class:{ 'hide-bio': _vm.hideBio },style:(_vm.style)}),_vm._v(\" \"),_c('div',{staticClass:\"panel-heading\"},[_c('div',{staticClass:\"user-info\"},[_c('div',{staticClass:\"container\"},[(_vm.allowZoomingAvatar)?_c('a',{staticClass:\"user-info-avatar-link\",on:{\"click\":_vm.zoomAvatar}},[_c('UserAvatar',{attrs:{\"better-shadow\":_vm.betterShadow,\"user\":_vm.user}}),_vm._v(\" \"),_vm._m(0)],1):_c('router-link',{attrs:{\"to\":_vm.userProfileLink(_vm.user)}},[_c('UserAvatar',{attrs:{\"better-shadow\":_vm.betterShadow,\"user\":_vm.user}})],1),_vm._v(\" \"),_c('div',{staticClass:\"user-summary\"},[_c('div',{staticClass:\"top-line\"},[(_vm.user.name_html)?_c('div',{staticClass:\"user-name\",attrs:{\"title\":_vm.user.name},domProps:{\"innerHTML\":_vm._s(_vm.user.name_html)}}):_c('div',{staticClass:\"user-name\",attrs:{\"title\":_vm.user.name}},[_vm._v(\"\\n \"+_vm._s(_vm.user.name)+\"\\n \")]),_vm._v(\" \"),(!_vm.isOtherUser)?_c('router-link',{attrs:{\"to\":{ name: 'user-settings' }}},[_c('i',{staticClass:\"button-icon icon-wrench usersettings\",attrs:{\"title\":_vm.$t('tool_tip.user_settings')}})]):_vm._e(),_vm._v(\" \"),(_vm.isOtherUser && !_vm.user.is_local)?_c('a',{attrs:{\"href\":_vm.user.statusnet_profile_url,\"target\":\"_blank\"}},[_c('i',{staticClass:\"icon-link-ext usersettings\"})]):_vm._e(),_vm._v(\" \"),(_vm.isOtherUser && _vm.loggedIn)?_c('AccountActions',{attrs:{\"user\":_vm.user}}):_vm._e()],1),_vm._v(\" \"),_c('div',{staticClass:\"bottom-line\"},[_c('router-link',{staticClass:\"user-screen-name\",attrs:{\"to\":_vm.userProfileLink(_vm.user)}},[_vm._v(\"\\n @\"+_vm._s(_vm.user.screen_name)+\"\\n \")]),_vm._v(\" \"),(!_vm.hideBio && !!_vm.visibleRole)?_c('span',{staticClass:\"alert staff\"},[_vm._v(_vm._s(_vm.visibleRole))]):_vm._e(),_vm._v(\" \"),(_vm.user.locked)?_c('span',[_c('i',{staticClass:\"icon icon-lock\"})]):_vm._e(),_vm._v(\" \"),(!_vm.mergedConfig.hideUserStats && !_vm.hideBio)?_c('span',{staticClass:\"dailyAvg\"},[_vm._v(_vm._s(_vm.dailyAvg)+\" \"+_vm._s(_vm.$t('user_card.per_day')))]):_vm._e()],1)])],1),_vm._v(\" \"),_c('div',{staticClass:\"user-meta\"},[(_vm.user.follows_you && _vm.loggedIn && _vm.isOtherUser)?_c('div',{staticClass:\"following\"},[_vm._v(\"\\n \"+_vm._s(_vm.$t('user_card.follows_you'))+\"\\n \")]):_vm._e(),_vm._v(\" \"),(_vm.isOtherUser && (_vm.loggedIn || !_vm.switcher))?_c('div',{staticClass:\"highlighter\"},[(_vm.userHighlightType !== 'disabled')?_c('input',{directives:[{name:\"model\",rawName:\"v-model\",value:(_vm.userHighlightColor),expression:\"userHighlightColor\"}],staticClass:\"userHighlightText\",attrs:{\"id\":'userHighlightColorTx'+_vm.user.id,\"type\":\"text\"},domProps:{\"value\":(_vm.userHighlightColor)},on:{\"input\":function($event){if($event.target.composing){ return; }_vm.userHighlightColor=$event.target.value}}}):_vm._e(),_vm._v(\" \"),(_vm.userHighlightType !== 'disabled')?_c('input',{directives:[{name:\"model\",rawName:\"v-model\",value:(_vm.userHighlightColor),expression:\"userHighlightColor\"}],staticClass:\"userHighlightCl\",attrs:{\"id\":'userHighlightColor'+_vm.user.id,\"type\":\"color\"},domProps:{\"value\":(_vm.userHighlightColor)},on:{\"input\":function($event){if($event.target.composing){ return; }_vm.userHighlightColor=$event.target.value}}}):_vm._e(),_vm._v(\" \"),_c('label',{staticClass:\"userHighlightSel select\",attrs:{\"for\":\"style-switcher\"}},[_c('select',{directives:[{name:\"model\",rawName:\"v-model\",value:(_vm.userHighlightType),expression:\"userHighlightType\"}],staticClass:\"userHighlightSel\",attrs:{\"id\":'userHighlightSel'+_vm.user.id},on:{\"change\":function($event){var $$selectedVal = Array.prototype.filter.call($event.target.options,function(o){return o.selected}).map(function(o){var val = \"_value\" in o ? o._value : o.value;return val}); _vm.userHighlightType=$event.target.multiple ? $$selectedVal : $$selectedVal[0]}}},[_c('option',{attrs:{\"value\":\"disabled\"}},[_vm._v(\"No highlight\")]),_vm._v(\" \"),_c('option',{attrs:{\"value\":\"solid\"}},[_vm._v(\"Solid bg\")]),_vm._v(\" \"),_c('option',{attrs:{\"value\":\"striped\"}},[_vm._v(\"Striped bg\")]),_vm._v(\" \"),_c('option',{attrs:{\"value\":\"side\"}},[_vm._v(\"Side stripe\")])]),_vm._v(\" \"),_c('i',{staticClass:\"icon-down-open\"})])]):_vm._e()]),_vm._v(\" \"),(_vm.loggedIn && _vm.isOtherUser)?_c('div',{staticClass:\"user-interactions\"},[_c('div',{staticClass:\"btn-group\"},[_c('FollowButton',{attrs:{\"user\":_vm.user}}),_vm._v(\" \"),(_vm.user.following)?[(!_vm.user.subscribed)?_c('ProgressButton',{staticClass:\"btn btn-default\",attrs:{\"click\":_vm.subscribeUser,\"title\":_vm.$t('user_card.subscribe')}},[_c('i',{staticClass:\"icon-bell-alt\"})]):_c('ProgressButton',{staticClass:\"btn btn-default pressed\",attrs:{\"click\":_vm.unsubscribeUser,\"title\":_vm.$t('user_card.unsubscribe')}},[_c('i',{staticClass:\"icon-bell-ringing-o\"})])]:_vm._e()],2),_vm._v(\" \"),_c('div',[(_vm.user.muted)?_c('button',{staticClass:\"btn btn-default btn-block pressed\",on:{\"click\":_vm.unmuteUser}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('user_card.muted'))+\"\\n \")]):_c('button',{staticClass:\"btn btn-default btn-block\",on:{\"click\":_vm.muteUser}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('user_card.mute'))+\"\\n \")])]),_vm._v(\" \"),(_vm.loggedIn.role === \"admin\")?_c('ModerationTools',{attrs:{\"user\":_vm.user}}):_vm._e()],1):_vm._e(),_vm._v(\" \"),(!_vm.loggedIn && _vm.user.is_local)?_c('div',{staticClass:\"user-interactions\"},[_c('RemoteFollow',{attrs:{\"user\":_vm.user}})],1):_vm._e()])]),_vm._v(\" \"),(!_vm.hideBio)?_c('div',{staticClass:\"panel-body\"},[(!_vm.mergedConfig.hideUserStats && _vm.switcher)?_c('div',{staticClass:\"user-counts\"},[_c('div',{staticClass:\"user-count\",on:{\"click\":function($event){$event.preventDefault();_vm.setProfileView('statuses')}}},[_c('h5',[_vm._v(_vm._s(_vm.$t('user_card.statuses')))]),_vm._v(\" \"),_c('span',[_vm._v(_vm._s(_vm.user.statuses_count)+\" \"),_c('br')])]),_vm._v(\" \"),_c('div',{staticClass:\"user-count\",on:{\"click\":function($event){$event.preventDefault();_vm.setProfileView('friends')}}},[_c('h5',[_vm._v(_vm._s(_vm.$t('user_card.followees')))]),_vm._v(\" \"),_c('span',[_vm._v(_vm._s(_vm.user.friends_count))])]),_vm._v(\" \"),_c('div',{staticClass:\"user-count\",on:{\"click\":function($event){$event.preventDefault();_vm.setProfileView('followers')}}},[_c('h5',[_vm._v(_vm._s(_vm.$t('user_card.followers')))]),_vm._v(\" \"),_c('span',[_vm._v(_vm._s(_vm.user.followers_count))])])]):_vm._e(),_vm._v(\" \"),(!_vm.hideBio && _vm.user.description_html)?_c('p',{staticClass:\"user-card-bio\",domProps:{\"innerHTML\":_vm._s(_vm.user.description_html)},on:{\"click\":function($event){$event.preventDefault();return _vm.linkClicked($event)}}}):(!_vm.hideBio)?_c('p',{staticClass:\"user-card-bio\"},[_vm._v(\"\\n \"+_vm._s(_vm.user.description)+\"\\n \")]):_vm._e()]):_vm._e()])}\nvar staticRenderFns = [function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:\"user-info-avatar-link-overlay\"},[_c('i',{staticClass:\"button-icon icon-zoom-in\"})])}]\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{ref:\"galleryContainer\",staticStyle:{\"width\":\"100%\"}},_vm._l((_vm.rows),function(row,index){return _c('div',{key:index,staticClass:\"gallery-row\",class:{ 'contain-fit': _vm.useContainFit, 'cover-fit': !_vm.useContainFit },style:(_vm.rowStyle(row.length))},[_c('div',{staticClass:\"gallery-row-inner\"},_vm._l((row),function(attachment){return _c('attachment',{key:attachment.id,style:(_vm.itemStyle(attachment.id, row)),attrs:{\"set-media\":_vm.setMedia,\"nsfw\":_vm.nsfw,\"attachment\":attachment,\"allow-play\":false,\"natural-size-load\":_vm.onNaturalSizeLoad.bind(null, attachment.id)}})}),1)])}),0)}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',[_c('a',{staticClass:\"link-preview-card\",attrs:{\"href\":_vm.card.url,\"target\":\"_blank\",\"rel\":\"noopener\"}},[(_vm.useImage && _vm.imageLoaded)?_c('div',{staticClass:\"card-image\",class:{ 'small-image': _vm.size === 'small' }},[_c('img',{attrs:{\"src\":_vm.card.image}})]):_vm._e(),_vm._v(\" \"),_c('div',{staticClass:\"card-content\"},[_c('span',{staticClass:\"card-host faint\"},[_vm._v(_vm._s(_vm.card.provider_name))]),_vm._v(\" \"),_c('h4',{staticClass:\"card-title\"},[_vm._v(_vm._s(_vm.card.title))]),_vm._v(\" \"),(_vm.useDescription)?_c('p',{staticClass:\"card-description\"},[_vm._v(_vm._s(_vm.card.description))]):_vm._e()])])])}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:\"avatars\"},_vm._l((_vm.slicedUsers),function(user){return _c('router-link',{key:user.id,staticClass:\"avatars-item\",attrs:{\"to\":_vm.userProfileLink(user)}},[_c('UserAvatar',{staticClass:\"avatar-small\",attrs:{\"user\":user}})],1)}),1)}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('v-popover',{attrs:{\"popover-class\":\"status-popover\",\"placement\":\"top-start\",\"popper-options\":_vm.popperOptions},on:{\"show\":function($event){_vm.enter()}}},[_c('template',{slot:\"popover\"},[(_vm.status)?_c('Status',{attrs:{\"is-preview\":true,\"statusoid\":_vm.status,\"compact\":true}}):_c('div',{staticClass:\"status-preview-loading\"},[_c('i',{staticClass:\"icon-spin4 animate-spin\"})])],1),_vm._v(\" \"),_vm._t(\"default\")],2)}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return (!_vm.hideStatus)?_c('div',{staticClass:\"status-el\",class:[{ 'status-el_focused': _vm.isFocused }, { 'status-conversation': _vm.inlineExpanded }]},[(_vm.error)?_c('div',{staticClass:\"alert error\"},[_vm._v(\"\\n \"+_vm._s(_vm.error)+\"\\n \"),_c('i',{staticClass:\"button-icon icon-cancel\",on:{\"click\":_vm.clearError}})]):_vm._e(),_vm._v(\" \"),(_vm.muted && !_vm.isPreview)?[_c('div',{staticClass:\"media status container muted\"},[_c('small',[_c('router-link',{attrs:{\"to\":_vm.userProfileLink}},[_vm._v(\"\\n \"+_vm._s(_vm.status.user.screen_name)+\"\\n \")])],1),_vm._v(\" \"),_c('small',{staticClass:\"muteWords\"},[_vm._v(_vm._s(_vm.muteWordHits.join(', ')))]),_vm._v(\" \"),_c('a',{staticClass:\"unmute\",attrs:{\"href\":\"#\"},on:{\"click\":function($event){$event.preventDefault();return _vm.toggleMute($event)}}},[_c('i',{staticClass:\"button-icon icon-eye-off\"})])])]:[(_vm.showPinned)?_c('div',{staticClass:\"status-pin\"},[_c('i',{staticClass:\"fa icon-pin faint\"}),_vm._v(\" \"),_c('span',{staticClass:\"faint\"},[_vm._v(_vm._s(_vm.$t('status.pinned')))])]):_vm._e(),_vm._v(\" \"),(_vm.retweet && !_vm.noHeading && !_vm.inConversation)?_c('div',{staticClass:\"media container retweet-info\",class:[_vm.repeaterClass, { highlighted: _vm.repeaterStyle }],style:([_vm.repeaterStyle])},[(_vm.retweet)?_c('UserAvatar',{staticClass:\"media-left\",attrs:{\"better-shadow\":_vm.betterShadow,\"user\":_vm.statusoid.user}}):_vm._e(),_vm._v(\" \"),_c('div',{staticClass:\"media-body faint\"},[_c('span',{staticClass:\"user-name\"},[(_vm.retweeterHtml)?_c('router-link',{attrs:{\"to\":_vm.retweeterProfileLink},domProps:{\"innerHTML\":_vm._s(_vm.retweeterHtml)}}):_c('router-link',{attrs:{\"to\":_vm.retweeterProfileLink}},[_vm._v(_vm._s(_vm.retweeter))])],1),_vm._v(\" \"),_c('i',{staticClass:\"fa icon-retweet retweeted\",attrs:{\"title\":_vm.$t('tool_tip.repeat')}}),_vm._v(\"\\n \"+_vm._s(_vm.$t('timeline.repeated'))+\"\\n \")])],1):_vm._e(),_vm._v(\" \"),_c('div',{staticClass:\"media status\",class:[_vm.userClass, { highlighted: _vm.userStyle, 'is-retweet': _vm.retweet && !_vm.inConversation }],style:([ _vm.userStyle ]),attrs:{\"data-tags\":_vm.tags}},[(!_vm.noHeading)?_c('div',{staticClass:\"media-left\"},[_c('router-link',{attrs:{\"to\":_vm.userProfileLink},nativeOn:{\"!click\":function($event){$event.stopPropagation();$event.preventDefault();return _vm.toggleUserExpanded($event)}}},[_c('UserAvatar',{attrs:{\"compact\":_vm.compact,\"better-shadow\":_vm.betterShadow,\"user\":_vm.status.user}})],1)],1):_vm._e(),_vm._v(\" \"),_c('div',{staticClass:\"status-body\"},[(_vm.userExpanded)?_c('UserCard',{staticClass:\"status-usercard\",attrs:{\"user\":_vm.status.user,\"rounded\":true,\"bordered\":true}}):_vm._e(),_vm._v(\" \"),(!_vm.noHeading)?_c('div',{staticClass:\"media-heading\"},[_c('div',{staticClass:\"heading-name-row\"},[_c('div',{staticClass:\"name-and-account-name\"},[(_vm.status.user.name_html)?_c('h4',{staticClass:\"user-name\",domProps:{\"innerHTML\":_vm._s(_vm.status.user.name_html)}}):_c('h4',{staticClass:\"user-name\"},[_vm._v(\"\\n \"+_vm._s(_vm.status.user.name)+\"\\n \")]),_vm._v(\" \"),_c('router-link',{staticClass:\"account-name\",attrs:{\"to\":_vm.userProfileLink}},[_vm._v(\"\\n \"+_vm._s(_vm.status.user.screen_name)+\"\\n \")])],1),_vm._v(\" \"),_c('span',{staticClass:\"heading-right\"},[_c('router-link',{staticClass:\"timeago faint-link\",attrs:{\"to\":{ name: 'conversation', params: { id: _vm.status.id } }}},[_c('Timeago',{attrs:{\"time\":_vm.status.created_at,\"auto-update\":60}})],1),_vm._v(\" \"),(_vm.status.visibility)?_c('div',{staticClass:\"button-icon visibility-icon\"},[_c('i',{class:_vm.visibilityIcon(_vm.status.visibility),attrs:{\"title\":_vm._f(\"capitalize\")(_vm.status.visibility)}})]):_vm._e(),_vm._v(\" \"),(!_vm.status.is_local && !_vm.isPreview)?_c('a',{staticClass:\"source_url\",attrs:{\"href\":_vm.status.external_url,\"target\":\"_blank\",\"title\":\"Source\"}},[_c('i',{staticClass:\"button-icon icon-link-ext-alt\"})]):_vm._e(),_vm._v(\" \"),(_vm.expandable && !_vm.isPreview)?[_c('a',{attrs:{\"href\":\"#\",\"title\":\"Expand\"},on:{\"click\":function($event){$event.preventDefault();return _vm.toggleExpanded($event)}}},[_c('i',{staticClass:\"button-icon icon-plus-squared\"})])]:_vm._e(),_vm._v(\" \"),(_vm.unmuted)?_c('a',{attrs:{\"href\":\"#\"},on:{\"click\":function($event){$event.preventDefault();return _vm.toggleMute($event)}}},[_c('i',{staticClass:\"button-icon icon-eye-off\"})]):_vm._e()],2)]),_vm._v(\" \"),_c('div',{staticClass:\"heading-reply-row\"},[(_vm.isReply)?_c('div',{staticClass:\"reply-to-and-accountname\"},[(!_vm.isPreview)?_c('StatusPopover',{attrs:{\"status-id\":_vm.status.in_reply_to_status_id}},[_c('a',{staticClass:\"reply-to\",attrs:{\"href\":\"#\",\"aria-label\":_vm.$t('tool_tip.reply')},on:{\"click\":function($event){$event.preventDefault();_vm.gotoOriginal(_vm.status.in_reply_to_status_id)}}},[_c('i',{staticClass:\"button-icon icon-reply\"}),_vm._v(\" \"),_c('span',{staticClass:\"faint-link reply-to-text\"},[_vm._v(_vm._s(_vm.$t('status.reply_to')))])])]):_c('span',{staticClass:\"reply-to\"},[_c('span',{staticClass:\"reply-to-text\"},[_vm._v(_vm._s(_vm.$t('status.reply_to')))])]),_vm._v(\" \"),_c('router-link',{attrs:{\"to\":_vm.replyProfileLink}},[_vm._v(\"\\n \"+_vm._s(_vm.replyToName)+\"\\n \")]),_vm._v(\" \"),(_vm.replies && _vm.replies.length)?_c('span',{staticClass:\"faint replies-separator\"},[_vm._v(\"\\n -\\n \")]):_vm._e()],1):_vm._e(),_vm._v(\" \"),(_vm.inConversation && !_vm.isPreview && _vm.replies && _vm.replies.length)?_c('div',{staticClass:\"replies\"},[_c('span',{staticClass:\"faint\"},[_vm._v(_vm._s(_vm.$t('status.replies_list')))]),_vm._v(\" \"),_vm._l((_vm.replies),function(reply){return _c('StatusPopover',{key:reply.id,attrs:{\"status-id\":reply.id}},[_c('a',{staticClass:\"reply-link\",attrs:{\"href\":\"#\"},on:{\"click\":function($event){$event.preventDefault();_vm.gotoOriginal(reply.id)}}},[_vm._v(_vm._s(reply.name))])])})],2):_vm._e()])]):_vm._e(),_vm._v(\" \"),(_vm.longSubject)?_c('div',{staticClass:\"status-content-wrapper\",class:{ 'tall-status': !_vm.showingLongSubject }},[(!_vm.showingLongSubject)?_c('a',{staticClass:\"tall-status-hider\",class:{ 'tall-status-hider_focused': _vm.isFocused },attrs:{\"href\":\"#\"},on:{\"click\":function($event){$event.preventDefault();_vm.showingLongSubject=true}}},[_vm._v(_vm._s(_vm.$t(\"general.show_more\")))]):_vm._e(),_vm._v(\" \"),_c('div',{staticClass:\"status-content media-body\",domProps:{\"innerHTML\":_vm._s(_vm.contentHtml)},on:{\"click\":function($event){$event.preventDefault();return _vm.linkClicked($event)}}}),_vm._v(\" \"),(_vm.showingLongSubject)?_c('a',{staticClass:\"status-unhider\",attrs:{\"href\":\"#\"},on:{\"click\":function($event){$event.preventDefault();_vm.showingLongSubject=false}}},[_vm._v(_vm._s(_vm.$t(\"general.show_less\")))]):_vm._e()]):_c('div',{staticClass:\"status-content-wrapper\",class:{'tall-status': _vm.hideTallStatus}},[(_vm.hideTallStatus)?_c('a',{staticClass:\"tall-status-hider\",class:{ 'tall-status-hider_focused': _vm.isFocused },attrs:{\"href\":\"#\"},on:{\"click\":function($event){$event.preventDefault();return _vm.toggleShowMore($event)}}},[_vm._v(_vm._s(_vm.$t(\"general.show_more\")))]):_vm._e(),_vm._v(\" \"),(!_vm.hideSubjectStatus)?_c('div',{staticClass:\"status-content media-body\",domProps:{\"innerHTML\":_vm._s(_vm.contentHtml)},on:{\"click\":function($event){$event.preventDefault();return _vm.linkClicked($event)}}}):_c('div',{staticClass:\"status-content media-body\",domProps:{\"innerHTML\":_vm._s(_vm.status.summary_html)},on:{\"click\":function($event){$event.preventDefault();return _vm.linkClicked($event)}}}),_vm._v(\" \"),(_vm.hideSubjectStatus)?_c('a',{staticClass:\"cw-status-hider\",attrs:{\"href\":\"#\"},on:{\"click\":function($event){$event.preventDefault();return _vm.toggleShowMore($event)}}},[_vm._v(_vm._s(_vm.$t(\"general.show_more\")))]):_vm._e(),_vm._v(\" \"),(_vm.showingMore)?_c('a',{staticClass:\"status-unhider\",attrs:{\"href\":\"#\"},on:{\"click\":function($event){$event.preventDefault();return _vm.toggleShowMore($event)}}},[_vm._v(_vm._s(_vm.$t(\"general.show_less\")))]):_vm._e()]),_vm._v(\" \"),(_vm.status.poll && _vm.status.poll.options)?_c('div',[_c('poll',{attrs:{\"base-poll\":_vm.status.poll}})],1):_vm._e(),_vm._v(\" \"),(_vm.status.attachments && (!_vm.hideSubjectStatus || _vm.showingLongSubject))?_c('div',{staticClass:\"attachments media-body\"},[_vm._l((_vm.nonGalleryAttachments),function(attachment){return _c('attachment',{key:attachment.id,staticClass:\"non-gallery\",attrs:{\"size\":_vm.attachmentSize,\"nsfw\":_vm.nsfwClickthrough,\"attachment\":attachment,\"allow-play\":true,\"set-media\":_vm.setMedia()}})}),_vm._v(\" \"),(_vm.galleryAttachments.length > 0)?_c('gallery',{attrs:{\"nsfw\":_vm.nsfwClickthrough,\"attachments\":_vm.galleryAttachments,\"set-media\":_vm.setMedia()}}):_vm._e()],2):_vm._e(),_vm._v(\" \"),(_vm.status.card && !_vm.hideSubjectStatus && !_vm.noHeading)?_c('div',{staticClass:\"link-preview media-body\"},[_c('link-preview',{attrs:{\"card\":_vm.status.card,\"size\":_vm.attachmentSize,\"nsfw\":_vm.nsfwClickthrough}})],1):_vm._e(),_vm._v(\" \"),_c('transition',{attrs:{\"name\":\"fade\"}},[(!_vm.hidePostStats && _vm.isFocused && _vm.combinedFavsAndRepeatsUsers.length > 0)?_c('div',{staticClass:\"favs-repeated-users\"},[_c('div',{staticClass:\"stats\"},[(_vm.statusFromGlobalRepository.rebloggedBy && _vm.statusFromGlobalRepository.rebloggedBy.length > 0)?_c('div',{staticClass:\"stat-count\"},[_c('a',{staticClass:\"stat-title\"},[_vm._v(_vm._s(_vm.$t('status.repeats')))]),_vm._v(\" \"),_c('div',{staticClass:\"stat-number\"},[_vm._v(\"\\n \"+_vm._s(_vm.statusFromGlobalRepository.rebloggedBy.length)+\"\\n \")])]):_vm._e(),_vm._v(\" \"),(_vm.statusFromGlobalRepository.favoritedBy && _vm.statusFromGlobalRepository.favoritedBy.length > 0)?_c('div',{staticClass:\"stat-count\"},[_c('a',{staticClass:\"stat-title\"},[_vm._v(_vm._s(_vm.$t('status.favorites')))]),_vm._v(\" \"),_c('div',{staticClass:\"stat-number\"},[_vm._v(\"\\n \"+_vm._s(_vm.statusFromGlobalRepository.favoritedBy.length)+\"\\n \")])]):_vm._e(),_vm._v(\" \"),_c('div',{staticClass:\"avatar-row\"},[_c('AvatarList',{attrs:{\"users\":_vm.combinedFavsAndRepeatsUsers}})],1)])]):_vm._e()]),_vm._v(\" \"),(!_vm.noHeading && !_vm.isPreview)?_c('div',{staticClass:\"status-actions media-body\"},[_c('div',[(_vm.loggedIn)?_c('i',{staticClass:\"button-icon icon-reply\",class:{'button-icon-active': _vm.replying},attrs:{\"title\":_vm.$t('tool_tip.reply')},on:{\"click\":function($event){$event.preventDefault();return _vm.toggleReplying($event)}}}):_c('i',{staticClass:\"button-icon button-icon-disabled icon-reply\",attrs:{\"title\":_vm.$t('tool_tip.reply')}}),_vm._v(\" \"),(_vm.status.replies_count > 0)?_c('span',[_vm._v(_vm._s(_vm.status.replies_count))]):_vm._e()]),_vm._v(\" \"),_c('retweet-button',{attrs:{\"visibility\":_vm.status.visibility,\"logged-in\":_vm.loggedIn,\"status\":_vm.status}}),_vm._v(\" \"),_c('favorite-button',{attrs:{\"logged-in\":_vm.loggedIn,\"status\":_vm.status}}),_vm._v(\" \"),_c('extra-buttons',{attrs:{\"status\":_vm.status},on:{\"onError\":_vm.showError,\"onSuccess\":_vm.clearError}})],1):_vm._e()],1)]),_vm._v(\" \"),(_vm.replying)?_c('div',{staticClass:\"container\"},[_c('PostStatusForm',{staticClass:\"reply-body\",attrs:{\"reply-to\":_vm.status.id,\"attentions\":_vm.status.attentions,\"replied-user\":_vm.status.user,\"copy-message-scope\":_vm.status.visibility,\"subject\":_vm.replySubject},on:{\"posted\":_vm.toggleReplying}})],1):_vm._e()]],2):_vm._e()}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:\"timeline panel-default\",class:[_vm.isExpanded ? 'panel' : 'panel-disabled']},[(_vm.isExpanded)?_c('div',{staticClass:\"panel-heading conversation-heading\"},[_c('span',{staticClass:\"title\"},[_vm._v(\" \"+_vm._s(_vm.$t('timeline.conversation'))+\" \")]),_vm._v(\" \"),(_vm.collapsable)?_c('span',[_c('a',{attrs:{\"href\":\"#\"},on:{\"click\":function($event){$event.preventDefault();return _vm.toggleExpanded($event)}}},[_vm._v(_vm._s(_vm.$t('timeline.collapse')))])]):_vm._e()]):_vm._e(),_vm._v(\" \"),_vm._l((_vm.conversation),function(status){return _c('status',{key:status.id,staticClass:\"status-fadein panel-body\",attrs:{\"inline-expanded\":_vm.collapsable && _vm.isExpanded,\"statusoid\":status,\"expandable\":!_vm.isExpanded,\"show-pinned\":_vm.pinnedStatusIdsObject && _vm.pinnedStatusIdsObject[status.id],\"focused\":_vm.focused(status.id),\"in-conversation\":_vm.isExpanded,\"highlight\":_vm.getHighlight(),\"replies\":_vm.getReplies(status.id),\"in-profile\":_vm.inProfile},on:{\"goto\":_vm.setHighlight,\"toggleExpanded\":_vm.toggleExpanded}})})],2)}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{class:_vm.classes.root},[_c('div',{class:_vm.classes.header},[_c('div',{staticClass:\"title\"},[_vm._v(\"\\n \"+_vm._s(_vm.title)+\"\\n \")]),_vm._v(\" \"),(_vm.timelineError)?_c('div',{staticClass:\"loadmore-error alert error\",on:{\"click\":function($event){$event.preventDefault();}}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('timeline.error_fetching'))+\"\\n \")]):_vm._e(),_vm._v(\" \"),(_vm.timeline.newStatusCount > 0 && !_vm.timelineError)?_c('button',{staticClass:\"loadmore-button\",on:{\"click\":function($event){$event.preventDefault();return _vm.showNewStatuses($event)}}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('timeline.show_new'))+_vm._s(_vm.newStatusCountStr)+\"\\n \")]):_vm._e(),_vm._v(\" \"),(!_vm.timeline.newStatusCount > 0 && !_vm.timelineError)?_c('div',{staticClass:\"loadmore-text faint\",on:{\"click\":function($event){$event.preventDefault();}}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('timeline.up_to_date'))+\"\\n \")]):_vm._e()]),_vm._v(\" \"),_c('div',{class:_vm.classes.body},[_c('div',{staticClass:\"timeline\"},[_vm._l((_vm.pinnedStatusIds),function(statusId){return [(_vm.timeline.statusesObject[statusId])?_c('conversation',{key:statusId + '-pinned',staticClass:\"status-fadein\",attrs:{\"status-id\":statusId,\"collapsable\":true,\"pinned-status-ids-object\":_vm.pinnedStatusIdsObject,\"in-profile\":_vm.inProfile}}):_vm._e()]}),_vm._v(\" \"),_vm._l((_vm.timeline.visibleStatuses),function(status){return [(!_vm.excludedStatusIdsObject[status.id])?_c('conversation',{key:status.id,staticClass:\"status-fadein\",attrs:{\"status-id\":status.id,\"collapsable\":true,\"in-profile\":_vm.inProfile}}):_vm._e()]})],2)]),_vm._v(\" \"),_c('div',{class:_vm.classes.footer},[(_vm.count===0)?_c('div',{staticClass:\"new-status-notification text-center panel-footer faint\"},[_vm._v(\"\\n \"+_vm._s(_vm.$t('timeline.no_statuses'))+\"\\n \")]):(_vm.bottomedOut)?_c('div',{staticClass:\"new-status-notification text-center panel-footer faint\"},[_vm._v(\"\\n \"+_vm._s(_vm.$t('timeline.no_more_statuses'))+\"\\n \")]):(!_vm.timeline.loading)?_c('a',{attrs:{\"href\":\"#\"},on:{\"click\":function($event){$event.preventDefault();_vm.fetchOlderStatuses()}}},[_c('div',{staticClass:\"new-status-notification text-center panel-footer\"},[_vm._v(_vm._s(_vm.$t('timeline.load_older')))])]):_c('div',{staticClass:\"new-status-notification text-center panel-footer\"},[_c('i',{staticClass:\"icon-spin3 animate-spin\"})])])])}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('Timeline',{attrs:{\"title\":_vm.$t('nav.public_tl'),\"timeline\":_vm.timeline,\"timeline-name\":'public'}})}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('Timeline',{attrs:{\"title\":_vm.$t('nav.twkn'),\"timeline\":_vm.timeline,\"timeline-name\":'publicAndExternal'}})}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('Timeline',{attrs:{\"title\":_vm.$t('nav.timeline'),\"timeline\":_vm.timeline,\"timeline-name\":'friends'}})}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('Timeline',{attrs:{\"title\":_vm.tag,\"timeline\":_vm.timeline,\"timeline-name\":'tag',\"tag\":_vm.tag}})}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('conversation',{attrs:{\"collapsable\":false,\"is-page\":\"true\",\"status-id\":_vm.statusId}})}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return (_vm.notification.type === 'mention')?_c('status',{attrs:{\"compact\":true,\"statusoid\":_vm.notification.status}}):_c('div',[(_vm.needMute && !_vm.unmuted)?_c('div',{staticClass:\"container muted\"},[_c('small',[_c('router-link',{attrs:{\"to\":_vm.userProfileLink}},[_vm._v(\"\\n \"+_vm._s(_vm.notification.from_profile.screen_name)+\"\\n \")])],1),_vm._v(\" \"),_c('a',{staticClass:\"unmute\",attrs:{\"href\":\"#\"},on:{\"click\":function($event){$event.preventDefault();return _vm.toggleMute($event)}}},[_c('i',{staticClass:\"button-icon icon-eye-off\"})])]):_c('div',{staticClass:\"non-mention\",class:[_vm.userClass, { highlighted: _vm.userStyle }],style:([ _vm.userStyle ])},[_c('a',{staticClass:\"avatar-container\",attrs:{\"href\":_vm.notification.from_profile.statusnet_profile_url},on:{\"!click\":function($event){$event.stopPropagation();$event.preventDefault();return _vm.toggleUserExpanded($event)}}},[_c('UserAvatar',{attrs:{\"compact\":true,\"better-shadow\":_vm.betterShadow,\"user\":_vm.notification.from_profile}})],1),_vm._v(\" \"),_c('div',{staticClass:\"notification-right\"},[(_vm.userExpanded)?_c('UserCard',{attrs:{\"user\":_vm.getUser(_vm.notification),\"rounded\":true,\"bordered\":true}}):_vm._e(),_vm._v(\" \"),_c('span',{staticClass:\"notification-details\"},[_c('div',{staticClass:\"name-and-action\"},[(!!_vm.notification.from_profile.name_html)?_c('span',{staticClass:\"username\",attrs:{\"title\":'@'+_vm.notification.from_profile.screen_name},domProps:{\"innerHTML\":_vm._s(_vm.notification.from_profile.name_html)}}):_c('span',{staticClass:\"username\",attrs:{\"title\":'@'+_vm.notification.from_profile.screen_name}},[_vm._v(_vm._s(_vm.notification.from_profile.name))]),_vm._v(\" \"),(_vm.notification.type === 'like')?_c('span',[_c('i',{staticClass:\"fa icon-star lit\"}),_vm._v(\" \"),_c('small',[_vm._v(_vm._s(_vm.$t('notifications.favorited_you')))])]):_vm._e(),_vm._v(\" \"),(_vm.notification.type === 'repeat')?_c('span',[_c('i',{staticClass:\"fa icon-retweet lit\",attrs:{\"title\":_vm.$t('tool_tip.repeat')}}),_vm._v(\" \"),_c('small',[_vm._v(_vm._s(_vm.$t('notifications.repeated_you')))])]):_vm._e(),_vm._v(\" \"),(_vm.notification.type === 'follow')?_c('span',[_c('i',{staticClass:\"fa icon-user-plus lit\"}),_vm._v(\" \"),_c('small',[_vm._v(_vm._s(_vm.$t('notifications.followed_you')))])]):_vm._e()]),_vm._v(\" \"),(_vm.notification.type === 'follow')?_c('div',{staticClass:\"timeago\"},[_c('span',{staticClass:\"faint\"},[_c('Timeago',{attrs:{\"time\":_vm.notification.created_at,\"auto-update\":240}})],1)]):_c('div',{staticClass:\"timeago\"},[(_vm.notification.status)?_c('router-link',{staticClass:\"faint-link\",attrs:{\"to\":{ name: 'conversation', params: { id: _vm.notification.status.id } }}},[_c('Timeago',{attrs:{\"time\":_vm.notification.created_at,\"auto-update\":240}})],1):_vm._e()],1),_vm._v(\" \"),(_vm.needMute)?_c('a',{attrs:{\"href\":\"#\"},on:{\"click\":function($event){$event.preventDefault();return _vm.toggleMute($event)}}},[_c('i',{staticClass:\"button-icon icon-eye-off\"})]):_vm._e()]),_vm._v(\" \"),(_vm.notification.type === 'follow')?_c('div',{staticClass:\"follow-text\"},[_c('router-link',{attrs:{\"to\":_vm.userProfileLink}},[_vm._v(\"\\n @\"+_vm._s(_vm.notification.from_profile.screen_name)+\"\\n \")])],1):[_c('status',{staticClass:\"faint\",attrs:{\"compact\":true,\"statusoid\":_vm.notification.action,\"no-heading\":true}})]],2)])])}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:\"notifications\",class:{ minimal: _vm.minimalMode }},[_c('div',{class:_vm.mainClass},[(!_vm.noHeading)?_c('div',{staticClass:\"panel-heading\"},[_c('div',{staticClass:\"title\"},[_vm._v(\"\\n \"+_vm._s(_vm.$t('notifications.notifications'))+\"\\n \"),(_vm.unseenCount)?_c('span',{staticClass:\"badge badge-notification unseen-count\"},[_vm._v(_vm._s(_vm.unseenCount))]):_vm._e()]),_vm._v(\" \"),(_vm.error)?_c('div',{staticClass:\"loadmore-error alert error\",on:{\"click\":function($event){$event.preventDefault();}}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('timeline.error_fetching'))+\"\\n \")]):_vm._e(),_vm._v(\" \"),(_vm.unseenCount)?_c('button',{staticClass:\"read-button\",on:{\"click\":function($event){$event.preventDefault();return _vm.markAsSeen($event)}}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('notifications.read'))+\"\\n \")]):_vm._e()]):_vm._e(),_vm._v(\" \"),_c('div',{staticClass:\"panel-body\"},_vm._l((_vm.visibleNotifications),function(notification){return _c('div',{key:notification.id,staticClass:\"notification\",class:{\"unseen\": !_vm.minimalMode && !notification.seen}},[_c('div',{staticClass:\"notification-overlay\"}),_vm._v(\" \"),_c('notification',{attrs:{\"notification\":notification}})],1)}),0),_vm._v(\" \"),_c('div',{staticClass:\"panel-footer\"},[(_vm.bottomedOut)?_c('div',{staticClass:\"new-status-notification text-center panel-footer faint\"},[_vm._v(\"\\n \"+_vm._s(_vm.$t('notifications.no_more_notifications'))+\"\\n \")]):(!_vm.loading)?_c('a',{attrs:{\"href\":\"#\"},on:{\"click\":function($event){$event.preventDefault();_vm.fetchOlderNotifications()}}},[_c('div',{staticClass:\"new-status-notification text-center panel-footer\"},[_vm._v(\"\\n \"+_vm._s(_vm.minimalMode ? _vm.$t('interactions.load_older') : _vm.$t('notifications.load_older'))+\"\\n \")])]):_c('div',{staticClass:\"new-status-notification text-center panel-footer\"},[_c('i',{staticClass:\"icon-spin3 animate-spin\"})])])])])}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:\"panel panel-default\"},[_c('div',{staticClass:\"panel-heading\"},[_c('div',{staticClass:\"title\"},[_vm._v(\"\\n \"+_vm._s(_vm.$t(\"nav.interactions\"))+\"\\n \")])]),_vm._v(\" \"),_c('tab-switcher',{ref:\"tabSwitcher\",attrs:{\"on-switch\":_vm.onModeSwitch}},[_c('span',{key:\"mentions\",attrs:{\"label\":_vm.$t('nav.mentions')}}),_vm._v(\" \"),_c('span',{key:\"likes+repeats\",attrs:{\"label\":_vm.$t('interactions.favs_repeats')}}),_vm._v(\" \"),_c('span',{key:\"follows\",attrs:{\"label\":_vm.$t('interactions.follows')}})]),_vm._v(\" \"),_c('Notifications',{ref:\"notifications\",attrs:{\"no-heading\":true,\"minimal-mode\":true,\"filter-mode\":_vm.filterMode}})],1)}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('Timeline',{attrs:{\"title\":_vm.$t('nav.dms'),\"timeline\":_vm.timeline,\"timeline-name\":'dms'}})}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:\"basic-user-card\"},[_c('router-link',{attrs:{\"to\":_vm.userProfileLink(_vm.user)}},[_c('UserAvatar',{staticClass:\"avatar\",attrs:{\"user\":_vm.user},nativeOn:{\"click\":function($event){$event.preventDefault();return _vm.toggleUserExpanded($event)}}})],1),_vm._v(\" \"),(_vm.userExpanded)?_c('div',{staticClass:\"basic-user-card-expanded-content\"},[_c('UserCard',{attrs:{\"user\":_vm.user,\"rounded\":true,\"bordered\":true}})],1):_c('div',{staticClass:\"basic-user-card-collapsed-content\"},[_c('div',{staticClass:\"basic-user-card-user-name\",attrs:{\"title\":_vm.user.name}},[(_vm.user.name_html)?_c('span',{staticClass:\"basic-user-card-user-name-value\",domProps:{\"innerHTML\":_vm._s(_vm.user.name_html)}}):_c('span',{staticClass:\"basic-user-card-user-name-value\"},[_vm._v(_vm._s(_vm.user.name))])]),_vm._v(\" \"),_c('div',[_c('router-link',{staticClass:\"basic-user-card-screen-name\",attrs:{\"to\":_vm.userProfileLink(_vm.user)}},[_vm._v(\"\\n @\"+_vm._s(_vm.user.screen_name)+\"\\n \")])],1),_vm._v(\" \"),_vm._t(\"default\")],2)],1)}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('basic-user-card',{attrs:{\"user\":_vm.user}},[_c('div',{staticClass:\"follow-card-content-container\"},[(!_vm.noFollowsYou && _vm.user.follows_you)?_c('span',{staticClass:\"faint\"},[_vm._v(\"\\n \"+_vm._s(_vm.isMe ? _vm.$t('user_card.its_you') : _vm.$t('user_card.follows_you'))+\"\\n \")]):_vm._e(),_vm._v(\" \"),(!_vm.loggedIn)?[(!_vm.user.following)?_c('div',{staticClass:\"follow-card-follow-button\"},[_c('RemoteFollow',{attrs:{\"user\":_vm.user}})],1):_vm._e()]:[_c('FollowButton',{staticClass:\"follow-card-follow-button\",attrs:{\"user\":_vm.user,\"label-following\":_vm.$t('user_card.follow_unfollow')}})]],2)])}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:\"list\"},[_vm._l((_vm.items),function(item){return _c('div',{key:_vm.getKey(item),staticClass:\"list-item\"},[_vm._t(\"item\",null,{item:item})],2)}),_vm._v(\" \"),(_vm.items.length === 0 && !!_vm.$slots.empty)?_c('div',{staticClass:\"list-empty-content faint\"},[_vm._t(\"empty\")],2):_vm._e()],2)}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',[(_vm.user)?_c('div',{staticClass:\"user-profile panel panel-default\"},[_c('UserCard',{attrs:{\"user\":_vm.user,\"switcher\":true,\"selected\":_vm.timeline.viewing,\"allow-zooming-avatar\":true,\"rounded\":\"top\"}}),_vm._v(\" \"),_c('tab-switcher',{attrs:{\"active-tab\":_vm.tab,\"render-only-focused\":true,\"on-switch\":_vm.onTabSwitch}},[_c('Timeline',{key:\"statuses\",attrs:{\"label\":_vm.$t('user_card.statuses'),\"count\":_vm.user.statuses_count,\"embedded\":true,\"title\":_vm.$t('user_profile.timeline_title'),\"timeline\":_vm.timeline,\"timeline-name\":\"user\",\"user-id\":_vm.userId,\"pinned-status-ids\":_vm.user.pinnedStatusIds,\"in-profile\":true}}),_vm._v(\" \"),(_vm.followsTabVisible)?_c('div',{key:\"followees\",attrs:{\"label\":_vm.$t('user_card.followees'),\"disabled\":!_vm.user.friends_count}},[_c('FriendList',{attrs:{\"user-id\":_vm.userId},scopedSlots:_vm._u([{key:\"item\",fn:function(ref){\nvar item = ref.item;\nreturn [_c('FollowCard',{attrs:{\"user\":item}})]}}])})],1):_vm._e(),_vm._v(\" \"),(_vm.followersTabVisible)?_c('div',{key:\"followers\",attrs:{\"label\":_vm.$t('user_card.followers'),\"disabled\":!_vm.user.followers_count}},[_c('FollowerList',{attrs:{\"user-id\":_vm.userId},scopedSlots:_vm._u([{key:\"item\",fn:function(ref){\nvar item = ref.item;\nreturn [_c('FollowCard',{attrs:{\"user\":item,\"no-follows-you\":_vm.isUs}})]}}])})],1):_vm._e(),_vm._v(\" \"),_c('Timeline',{key:\"media\",attrs:{\"label\":_vm.$t('user_card.media'),\"disabled\":!_vm.media.visibleStatuses.length,\"embedded\":true,\"title\":_vm.$t('user_card.media'),\"timeline-name\":\"media\",\"timeline\":_vm.media,\"user-id\":_vm.userId,\"in-profile\":true}}),_vm._v(\" \"),(_vm.isUs)?_c('Timeline',{key:\"favorites\",attrs:{\"label\":_vm.$t('user_card.favorites'),\"disabled\":!_vm.favorites.visibleStatuses.length,\"embedded\":true,\"title\":_vm.$t('user_card.favorites'),\"timeline-name\":\"favorites\",\"timeline\":_vm.favorites,\"in-profile\":true}}):_vm._e()],1)],1):_c('div',{staticClass:\"panel user-profile-placeholder\"},[_c('div',{staticClass:\"panel-heading\"},[_c('div',{staticClass:\"title\"},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.profile_tab'))+\"\\n \")])]),_vm._v(\" \"),_c('div',{staticClass:\"panel-body\"},[(_vm.error)?_c('span',[_vm._v(_vm._s(_vm.error))]):_c('i',{staticClass:\"icon-spin3 animate-spin\"})])])])}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:\"panel panel-default\"},[_c('div',{staticClass:\"panel-heading\"},[_c('div',{staticClass:\"title\"},[_vm._v(\"\\n \"+_vm._s(_vm.$t('nav.search'))+\"\\n \")])]),_vm._v(\" \"),_c('div',{staticClass:\"search-input-container\"},[_c('input',{directives:[{name:\"model\",rawName:\"v-model\",value:(_vm.searchTerm),expression:\"searchTerm\"}],ref:\"searchInput\",staticClass:\"search-input\",attrs:{\"placeholder\":_vm.$t('nav.search')},domProps:{\"value\":(_vm.searchTerm)},on:{\"keyup\":function($event){if(!('button' in $event)&&_vm._k($event.keyCode,\"enter\",13,$event.key,\"Enter\")){ return null; }_vm.newQuery(_vm.searchTerm)},\"input\":function($event){if($event.target.composing){ return; }_vm.searchTerm=$event.target.value}}}),_vm._v(\" \"),_c('button',{staticClass:\"btn search-button\",on:{\"click\":function($event){_vm.newQuery(_vm.searchTerm)}}},[_c('i',{staticClass:\"icon-search\"})])]),_vm._v(\" \"),(_vm.loading)?_c('div',{staticClass:\"text-center loading-icon\"},[_c('i',{staticClass:\"icon-spin3 animate-spin\"})]):(_vm.loaded)?_c('div',[_c('div',{staticClass:\"search-nav-heading\"},[_c('tab-switcher',{ref:\"tabSwitcher\",attrs:{\"on-switch\":_vm.onResultTabSwitch,\"active-tab\":_vm.currenResultTab}},[_c('span',{key:\"statuses\",attrs:{\"label\":_vm.$t('user_card.statuses') + _vm.resultCount('visibleStatuses')}}),_vm._v(\" \"),_c('span',{key:\"people\",attrs:{\"label\":_vm.$t('search.people') + _vm.resultCount('users')}}),_vm._v(\" \"),_c('span',{key:\"hashtags\",attrs:{\"label\":_vm.$t('search.hashtags') + _vm.resultCount('hashtags')}})])],1)]):_vm._e(),_vm._v(\" \"),_c('div',{staticClass:\"panel-body\"},[(_vm.currenResultTab === 'statuses')?_c('div',[(_vm.visibleStatuses.length === 0 && !_vm.loading && _vm.loaded)?_c('div',{staticClass:\"search-result-heading\"},[_c('h4',[_vm._v(_vm._s(_vm.$t('search.no_results')))])]):_vm._e(),_vm._v(\" \"),_vm._l((_vm.visibleStatuses),function(status){return _c('Status',{key:status.id,staticClass:\"search-result\",attrs:{\"collapsable\":false,\"expandable\":false,\"compact\":false,\"statusoid\":status,\"no-heading\":false}})})],2):(_vm.currenResultTab === 'people')?_c('div',[(_vm.users.length === 0 && !_vm.loading && _vm.loaded)?_c('div',{staticClass:\"search-result-heading\"},[_c('h4',[_vm._v(_vm._s(_vm.$t('search.no_results')))])]):_vm._e(),_vm._v(\" \"),_vm._l((_vm.users),function(user){return _c('FollowCard',{key:user.id,staticClass:\"list-item search-result\",attrs:{\"user\":user}})})],2):(_vm.currenResultTab === 'hashtags')?_c('div',[(_vm.hashtags.length === 0 && !_vm.loading && _vm.loaded)?_c('div',{staticClass:\"search-result-heading\"},[_c('h4',[_vm._v(_vm._s(_vm.$t('search.no_results')))])]):_vm._e(),_vm._v(\" \"),_vm._l((_vm.hashtags),function(hashtag){return _c('div',{key:hashtag.url,staticClass:\"status trend search-result\"},[_c('div',{staticClass:\"hashtag\"},[_c('router-link',{attrs:{\"to\":{ name: 'tag-timeline', params: { tag: hashtag.name } }}},[_vm._v(\"\\n #\"+_vm._s(hashtag.name)+\"\\n \")]),_vm._v(\" \"),(_vm.lastHistoryRecord(hashtag))?_c('div',[(_vm.lastHistoryRecord(hashtag).accounts == 1)?_c('span',[_vm._v(\"\\n \"+_vm._s(_vm.$t('search.person_talking', { count: _vm.lastHistoryRecord(hashtag).accounts }))+\"\\n \")]):_c('span',[_vm._v(\"\\n \"+_vm._s(_vm.$t('search.people_talking', { count: _vm.lastHistoryRecord(hashtag).accounts }))+\"\\n \")])]):_vm._e()],1),_vm._v(\" \"),(_vm.lastHistoryRecord(hashtag))?_c('div',{staticClass:\"count\"},[_vm._v(\"\\n \"+_vm._s(_vm.lastHistoryRecord(hashtag).uses)+\"\\n \")]):_vm._e()])})],2):_vm._e()]),_vm._v(\" \"),_c('div',{staticClass:\"search-result-footer text-center panel-footer faint\"})])}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:\"color-control style-control\",class:{ disabled: !_vm.present || _vm.disabled }},[_c('label',{staticClass:\"label\",attrs:{\"for\":_vm.name}},[_vm._v(\"\\n \"+_vm._s(_vm.label)+\"\\n \")]),_vm._v(\" \"),(typeof _vm.fallback !== 'undefined')?_c('input',{staticClass:\"opt exlcude-disabled\",attrs:{\"id\":_vm.name + '-o',\"type\":\"checkbox\"},domProps:{\"checked\":_vm.present},on:{\"input\":function($event){_vm.$emit('input', typeof _vm.value === 'undefined' ? _vm.fallback : undefined)}}}):_vm._e(),_vm._v(\" \"),(typeof _vm.fallback !== 'undefined')?_c('label',{staticClass:\"opt-l\",attrs:{\"for\":_vm.name + '-o'}}):_vm._e(),_vm._v(\" \"),_c('input',{staticClass:\"color-input\",attrs:{\"id\":_vm.name,\"type\":\"color\",\"disabled\":!_vm.present || _vm.disabled},domProps:{\"value\":_vm.value || _vm.fallback},on:{\"input\":function($event){_vm.$emit('input', $event.target.value)}}}),_vm._v(\" \"),_c('input',{staticClass:\"text-input\",attrs:{\"id\":_vm.name + '-t',\"type\":\"text\",\"disabled\":!_vm.present || _vm.disabled},domProps:{\"value\":_vm.value || _vm.fallback},on:{\"input\":function($event){_vm.$emit('input', $event.target.value)}}})])}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:\"range-control style-control\",class:{ disabled: !_vm.present || _vm.disabled }},[_c('label',{staticClass:\"label\",attrs:{\"for\":_vm.name}},[_vm._v(\"\\n \"+_vm._s(_vm.label)+\"\\n \")]),_vm._v(\" \"),(typeof _vm.fallback !== 'undefined')?_c('input',{staticClass:\"opt exclude-disabled\",attrs:{\"id\":_vm.name + '-o',\"type\":\"checkbox\"},domProps:{\"checked\":_vm.present},on:{\"input\":function($event){_vm.$emit('input', !_vm.present ? _vm.fallback : undefined)}}}):_vm._e(),_vm._v(\" \"),(typeof _vm.fallback !== 'undefined')?_c('label',{staticClass:\"opt-l\",attrs:{\"for\":_vm.name + '-o'}}):_vm._e(),_vm._v(\" \"),_c('input',{staticClass:\"input-number\",attrs:{\"id\":_vm.name,\"type\":\"range\",\"disabled\":!_vm.present || _vm.disabled,\"max\":_vm.max || _vm.hardMax || 100,\"min\":_vm.min || _vm.hardMin || 0,\"step\":_vm.step || 1},domProps:{\"value\":_vm.value || _vm.fallback},on:{\"input\":function($event){_vm.$emit('input', $event.target.value)}}}),_vm._v(\" \"),_c('input',{staticClass:\"input-number\",attrs:{\"id\":_vm.name,\"type\":\"number\",\"disabled\":!_vm.present || _vm.disabled,\"max\":_vm.hardMax,\"min\":_vm.hardMin,\"step\":_vm.step || 1},domProps:{\"value\":_vm.value || _vm.fallback},on:{\"input\":function($event){_vm.$emit('input', $event.target.value)}}})])}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:\"opacity-control style-control\",class:{ disabled: !_vm.present || _vm.disabled }},[_c('label',{staticClass:\"label\",attrs:{\"for\":_vm.name}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.style.common.opacity'))+\"\\n \")]),_vm._v(\" \"),(typeof _vm.fallback !== 'undefined')?_c('input',{staticClass:\"opt exclude-disabled\",attrs:{\"id\":_vm.name + '-o',\"type\":\"checkbox\"},domProps:{\"checked\":_vm.present},on:{\"input\":function($event){_vm.$emit('input', !_vm.present ? _vm.fallback : undefined)}}}):_vm._e(),_vm._v(\" \"),(typeof _vm.fallback !== 'undefined')?_c('label',{staticClass:\"opt-l\",attrs:{\"for\":_vm.name + '-o'}}):_vm._e(),_vm._v(\" \"),_c('input',{staticClass:\"input-number\",attrs:{\"id\":_vm.name,\"type\":\"number\",\"disabled\":!_vm.present || _vm.disabled,\"max\":\"1\",\"min\":\"0\",\"step\":\".05\"},domProps:{\"value\":_vm.value || _vm.fallback},on:{\"input\":function($event){_vm.$emit('input', $event.target.value)}}})])}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:\"shadow-control\",class:{ disabled: !_vm.present }},[_c('div',{staticClass:\"shadow-preview-container\"},[_c('div',{staticClass:\"y-shift-control\",attrs:{\"disabled\":!_vm.present}},[_c('input',{directives:[{name:\"model\",rawName:\"v-model\",value:(_vm.selected.y),expression:\"selected.y\"}],staticClass:\"input-number\",attrs:{\"disabled\":!_vm.present,\"type\":\"number\"},domProps:{\"value\":(_vm.selected.y)},on:{\"input\":function($event){if($event.target.composing){ return; }_vm.$set(_vm.selected, \"y\", $event.target.value)}}}),_vm._v(\" \"),_c('div',{staticClass:\"wrap\"},[_c('input',{directives:[{name:\"model\",rawName:\"v-model\",value:(_vm.selected.y),expression:\"selected.y\"}],staticClass:\"input-range\",attrs:{\"disabled\":!_vm.present,\"type\":\"range\",\"max\":\"20\",\"min\":\"-20\"},domProps:{\"value\":(_vm.selected.y)},on:{\"__r\":function($event){_vm.$set(_vm.selected, \"y\", $event.target.value)}}})])]),_vm._v(\" \"),_c('div',{staticClass:\"preview-window\"},[_c('div',{staticClass:\"preview-block\",style:(_vm.style)})]),_vm._v(\" \"),_c('div',{staticClass:\"x-shift-control\",attrs:{\"disabled\":!_vm.present}},[_c('input',{directives:[{name:\"model\",rawName:\"v-model\",value:(_vm.selected.x),expression:\"selected.x\"}],staticClass:\"input-number\",attrs:{\"disabled\":!_vm.present,\"type\":\"number\"},domProps:{\"value\":(_vm.selected.x)},on:{\"input\":function($event){if($event.target.composing){ return; }_vm.$set(_vm.selected, \"x\", $event.target.value)}}}),_vm._v(\" \"),_c('div',{staticClass:\"wrap\"},[_c('input',{directives:[{name:\"model\",rawName:\"v-model\",value:(_vm.selected.x),expression:\"selected.x\"}],staticClass:\"input-range\",attrs:{\"disabled\":!_vm.present,\"type\":\"range\",\"max\":\"20\",\"min\":\"-20\"},domProps:{\"value\":(_vm.selected.x)},on:{\"__r\":function($event){_vm.$set(_vm.selected, \"x\", $event.target.value)}}})])])]),_vm._v(\" \"),_c('div',{staticClass:\"shadow-tweak\"},[_c('div',{staticClass:\"id-control style-control\",attrs:{\"disabled\":_vm.usingFallback}},[_c('label',{staticClass:\"select\",attrs:{\"for\":\"shadow-switcher\",\"disabled\":!_vm.ready || _vm.usingFallback}},[_c('select',{directives:[{name:\"model\",rawName:\"v-model\",value:(_vm.selectedId),expression:\"selectedId\"}],staticClass:\"shadow-switcher\",attrs:{\"id\":\"shadow-switcher\",\"disabled\":!_vm.ready || _vm.usingFallback},on:{\"change\":function($event){var $$selectedVal = Array.prototype.filter.call($event.target.options,function(o){return o.selected}).map(function(o){var val = \"_value\" in o ? o._value : o.value;return val}); _vm.selectedId=$event.target.multiple ? $$selectedVal : $$selectedVal[0]}}},_vm._l((_vm.cValue),function(shadow,index){return _c('option',{key:index,domProps:{\"value\":index}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.style.shadows.shadow_id', { value: index }))+\"\\n \")])}),0),_vm._v(\" \"),_c('i',{staticClass:\"icon-down-open\"})]),_vm._v(\" \"),_c('button',{staticClass:\"btn btn-default\",attrs:{\"disabled\":!_vm.ready || !_vm.present},on:{\"click\":_vm.del}},[_c('i',{staticClass:\"icon-cancel\"})]),_vm._v(\" \"),_c('button',{staticClass:\"btn btn-default\",attrs:{\"disabled\":!_vm.moveUpValid},on:{\"click\":_vm.moveUp}},[_c('i',{staticClass:\"icon-up-open\"})]),_vm._v(\" \"),_c('button',{staticClass:\"btn btn-default\",attrs:{\"disabled\":!_vm.moveDnValid},on:{\"click\":_vm.moveDn}},[_c('i',{staticClass:\"icon-down-open\"})]),_vm._v(\" \"),_c('button',{staticClass:\"btn btn-default\",attrs:{\"disabled\":_vm.usingFallback},on:{\"click\":_vm.add}},[_c('i',{staticClass:\"icon-plus\"})])]),_vm._v(\" \"),_c('div',{staticClass:\"inset-control style-control\",attrs:{\"disabled\":!_vm.present}},[_c('label',{staticClass:\"label\",attrs:{\"for\":\"inset\"}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.style.shadows.inset'))+\"\\n \")]),_vm._v(\" \"),_c('input',{directives:[{name:\"model\",rawName:\"v-model\",value:(_vm.selected.inset),expression:\"selected.inset\"}],staticClass:\"input-inset\",attrs:{\"id\":\"inset\",\"disabled\":!_vm.present,\"name\":\"inset\",\"type\":\"checkbox\"},domProps:{\"checked\":Array.isArray(_vm.selected.inset)?_vm._i(_vm.selected.inset,null)>-1:(_vm.selected.inset)},on:{\"change\":function($event){var $$a=_vm.selected.inset,$$el=$event.target,$$c=$$el.checked?(true):(false);if(Array.isArray($$a)){var $$v=null,$$i=_vm._i($$a,$$v);if($$el.checked){$$i<0&&(_vm.$set(_vm.selected, \"inset\", $$a.concat([$$v])))}else{$$i>-1&&(_vm.$set(_vm.selected, \"inset\", $$a.slice(0,$$i).concat($$a.slice($$i+1))))}}else{_vm.$set(_vm.selected, \"inset\", $$c)}}}}),_vm._v(\" \"),_c('label',{staticClass:\"checkbox-label\",attrs:{\"for\":\"inset\"}})]),_vm._v(\" \"),_c('div',{staticClass:\"blur-control style-control\",attrs:{\"disabled\":!_vm.present}},[_c('label',{staticClass:\"label\",attrs:{\"for\":\"spread\"}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.style.shadows.blur'))+\"\\n \")]),_vm._v(\" \"),_c('input',{directives:[{name:\"model\",rawName:\"v-model\",value:(_vm.selected.blur),expression:\"selected.blur\"}],staticClass:\"input-range\",attrs:{\"id\":\"blur\",\"disabled\":!_vm.present,\"name\":\"blur\",\"type\":\"range\",\"max\":\"20\",\"min\":\"0\"},domProps:{\"value\":(_vm.selected.blur)},on:{\"__r\":function($event){_vm.$set(_vm.selected, \"blur\", $event.target.value)}}}),_vm._v(\" \"),_c('input',{directives:[{name:\"model\",rawName:\"v-model\",value:(_vm.selected.blur),expression:\"selected.blur\"}],staticClass:\"input-number\",attrs:{\"disabled\":!_vm.present,\"type\":\"number\",\"min\":\"0\"},domProps:{\"value\":(_vm.selected.blur)},on:{\"input\":function($event){if($event.target.composing){ return; }_vm.$set(_vm.selected, \"blur\", $event.target.value)}}})]),_vm._v(\" \"),_c('div',{staticClass:\"spread-control style-control\",attrs:{\"disabled\":!_vm.present}},[_c('label',{staticClass:\"label\",attrs:{\"for\":\"spread\"}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.style.shadows.spread'))+\"\\n \")]),_vm._v(\" \"),_c('input',{directives:[{name:\"model\",rawName:\"v-model\",value:(_vm.selected.spread),expression:\"selected.spread\"}],staticClass:\"input-range\",attrs:{\"id\":\"spread\",\"disabled\":!_vm.present,\"name\":\"spread\",\"type\":\"range\",\"max\":\"20\",\"min\":\"-20\"},domProps:{\"value\":(_vm.selected.spread)},on:{\"__r\":function($event){_vm.$set(_vm.selected, \"spread\", $event.target.value)}}}),_vm._v(\" \"),_c('input',{directives:[{name:\"model\",rawName:\"v-model\",value:(_vm.selected.spread),expression:\"selected.spread\"}],staticClass:\"input-number\",attrs:{\"disabled\":!_vm.present,\"type\":\"number\"},domProps:{\"value\":(_vm.selected.spread)},on:{\"input\":function($event){if($event.target.composing){ return; }_vm.$set(_vm.selected, \"spread\", $event.target.value)}}})]),_vm._v(\" \"),_c('ColorInput',{attrs:{\"disabled\":!_vm.present,\"label\":_vm.$t('settings.style.common.color'),\"name\":\"shadow\"},model:{value:(_vm.selected.color),callback:function ($$v) {_vm.$set(_vm.selected, \"color\", $$v)},expression:\"selected.color\"}}),_vm._v(\" \"),_c('OpacityInput',{attrs:{\"disabled\":!_vm.present},model:{value:(_vm.selected.alpha),callback:function ($$v) {_vm.$set(_vm.selected, \"alpha\", $$v)},expression:\"selected.alpha\"}}),_vm._v(\" \"),_c('p',[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.style.shadows.hint'))+\"\\n \")])],1)])}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:\"font-control style-control\",class:{ custom: _vm.isCustom }},[_c('label',{staticClass:\"label\",attrs:{\"for\":_vm.preset === 'custom' ? _vm.name : _vm.name + '-font-switcher'}},[_vm._v(\"\\n \"+_vm._s(_vm.label)+\"\\n \")]),_vm._v(\" \"),(typeof _vm.fallback !== 'undefined')?_c('input',{staticClass:\"opt exlcude-disabled\",attrs:{\"id\":_vm.name + '-o',\"type\":\"checkbox\"},domProps:{\"checked\":_vm.present},on:{\"input\":function($event){_vm.$emit('input', typeof _vm.value === 'undefined' ? _vm.fallback : undefined)}}}):_vm._e(),_vm._v(\" \"),(typeof _vm.fallback !== 'undefined')?_c('label',{staticClass:\"opt-l\",attrs:{\"for\":_vm.name + '-o'}}):_vm._e(),_vm._v(\" \"),_c('label',{staticClass:\"select\",attrs:{\"for\":_vm.name + '-font-switcher',\"disabled\":!_vm.present}},[_c('select',{directives:[{name:\"model\",rawName:\"v-model\",value:(_vm.preset),expression:\"preset\"}],staticClass:\"font-switcher\",attrs:{\"id\":_vm.name + '-font-switcher',\"disabled\":!_vm.present},on:{\"change\":function($event){var $$selectedVal = Array.prototype.filter.call($event.target.options,function(o){return o.selected}).map(function(o){var val = \"_value\" in o ? o._value : o.value;return val}); _vm.preset=$event.target.multiple ? $$selectedVal : $$selectedVal[0]}}},_vm._l((_vm.availableOptions),function(option){return _c('option',{key:option,domProps:{\"value\":option}},[_vm._v(\"\\n \"+_vm._s(option === 'custom' ? _vm.$t('settings.style.fonts.custom') : option)+\"\\n \")])}),0),_vm._v(\" \"),_c('i',{staticClass:\"icon-down-open\"})]),_vm._v(\" \"),(_vm.isCustom)?_c('input',{directives:[{name:\"model\",rawName:\"v-model\",value:(_vm.family),expression:\"family\"}],staticClass:\"custom-font\",attrs:{\"id\":_vm.name,\"type\":\"text\"},domProps:{\"value\":(_vm.family)},on:{\"input\":function($event){if($event.target.composing){ return; }_vm.family=$event.target.value}}}):_vm._e()])}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return (_vm.contrast)?_c('span',{staticClass:\"contrast-ratio\"},[_c('span',{staticClass:\"rating\",attrs:{\"title\":_vm.hint}},[(_vm.contrast.aaa)?_c('span',[_c('i',{staticClass:\"icon-thumbs-up-alt\"})]):_vm._e(),_vm._v(\" \"),(!_vm.contrast.aaa && _vm.contrast.aa)?_c('span',[_c('i',{staticClass:\"icon-adjust\"})]):_vm._e(),_vm._v(\" \"),(!_vm.contrast.aaa && !_vm.contrast.aa)?_c('span',[_c('i',{staticClass:\"icon-attention\"})]):_vm._e()]),_vm._v(\" \"),(_vm.contrast && _vm.large)?_c('span',{staticClass:\"rating\",attrs:{\"title\":_vm.hint_18pt}},[(_vm.contrast.laaa)?_c('span',[_c('i',{staticClass:\"icon-thumbs-up-alt\"})]):_vm._e(),_vm._v(\" \"),(!_vm.contrast.laaa && _vm.contrast.laa)?_c('span',[_c('i',{staticClass:\"icon-adjust\"})]):_vm._e(),_vm._v(\" \"),(!_vm.contrast.laaa && !_vm.contrast.laa)?_c('span',[_c('i',{staticClass:\"icon-attention\"})]):_vm._e()]):_vm._e()]):_vm._e()}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:\"import-export-container\"},[_vm._t(\"before\"),_vm._v(\" \"),_c('button',{staticClass:\"btn\",on:{\"click\":_vm.exportData}},[_vm._v(\"\\n \"+_vm._s(_vm.exportLabel)+\"\\n \")]),_vm._v(\" \"),_c('button',{staticClass:\"btn\",on:{\"click\":_vm.importData}},[_vm._v(\"\\n \"+_vm._s(_vm.importLabel)+\"\\n \")]),_vm._v(\" \"),_vm._t(\"afterButtons\"),_vm._v(\" \"),(_vm.importFailed)?_c('p',{staticClass:\"alert error\"},[_vm._v(\"\\n \"+_vm._s(_vm.importFailedText)+\"\\n \")]):_vm._e(),_vm._v(\" \"),_vm._t(\"afterError\")],2)}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:\"style-switcher\"},[_c('div',{staticClass:\"presets-container\"},[_c('div',{staticClass:\"save-load\"},[_c('export-import',{attrs:{\"export-object\":_vm.exportedTheme,\"export-label\":_vm.$t(\"settings.export_theme\"),\"import-label\":_vm.$t(\"settings.import_theme\"),\"import-failed-text\":_vm.$t(\"settings.invalid_theme_imported\"),\"on-import\":_vm.onImport,\"validator\":_vm.importValidator}},[_c('template',{slot:\"before\"},[_c('div',{staticClass:\"presets\"},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.presets'))+\"\\n \"),_c('label',{staticClass:\"select\",attrs:{\"for\":\"preset-switcher\"}},[_c('select',{directives:[{name:\"model\",rawName:\"v-model\",value:(_vm.selected),expression:\"selected\"}],staticClass:\"preset-switcher\",attrs:{\"id\":\"preset-switcher\"},on:{\"change\":function($event){var $$selectedVal = Array.prototype.filter.call($event.target.options,function(o){return o.selected}).map(function(o){var val = \"_value\" in o ? o._value : o.value;return val}); _vm.selected=$event.target.multiple ? $$selectedVal : $$selectedVal[0]}}},_vm._l((_vm.availableStyles),function(style){return _c('option',{key:style.name,style:({\n backgroundColor: style[1] || style.theme.colors.bg,\n color: style[3] || style.theme.colors.text\n }),domProps:{\"value\":style}},[_vm._v(\"\\n \"+_vm._s(style[0] || style.name)+\"\\n \")])}),0),_vm._v(\" \"),_c('i',{staticClass:\"icon-down-open\"})])])])],2)],1),_vm._v(\" \"),_c('div',{staticClass:\"save-load-options\"},[_c('span',{staticClass:\"keep-option\"},[_c('Checkbox',{model:{value:(_vm.keepColor),callback:function ($$v) {_vm.keepColor=$$v},expression:\"keepColor\"}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.style.switcher.keep_color'))+\"\\n \")])],1),_vm._v(\" \"),_c('span',{staticClass:\"keep-option\"},[_c('Checkbox',{model:{value:(_vm.keepShadows),callback:function ($$v) {_vm.keepShadows=$$v},expression:\"keepShadows\"}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.style.switcher.keep_shadows'))+\"\\n \")])],1),_vm._v(\" \"),_c('span',{staticClass:\"keep-option\"},[_c('Checkbox',{model:{value:(_vm.keepOpacity),callback:function ($$v) {_vm.keepOpacity=$$v},expression:\"keepOpacity\"}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.style.switcher.keep_opacity'))+\"\\n \")])],1),_vm._v(\" \"),_c('span',{staticClass:\"keep-option\"},[_c('Checkbox',{model:{value:(_vm.keepRoundness),callback:function ($$v) {_vm.keepRoundness=$$v},expression:\"keepRoundness\"}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.style.switcher.keep_roundness'))+\"\\n \")])],1),_vm._v(\" \"),_c('span',{staticClass:\"keep-option\"},[_c('Checkbox',{model:{value:(_vm.keepFonts),callback:function ($$v) {_vm.keepFonts=$$v},expression:\"keepFonts\"}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.style.switcher.keep_fonts'))+\"\\n \")])],1),_vm._v(\" \"),_c('p',[_vm._v(_vm._s(_vm.$t('settings.style.switcher.save_load_hint')))])])]),_vm._v(\" \"),_c('div',{staticClass:\"preview-container\"},[_c('preview',{style:(_vm.previewRules)})],1),_vm._v(\" \"),_c('keep-alive',[_c('tab-switcher',{key:\"style-tweak\"},[_c('div',{staticClass:\"color-container\",attrs:{\"label\":_vm.$t('settings.style.common_colors._tab_label')}},[_c('div',{staticClass:\"tab-header\"},[_c('p',[_vm._v(_vm._s(_vm.$t('settings.theme_help')))]),_vm._v(\" \"),_c('button',{staticClass:\"btn\",on:{\"click\":_vm.clearOpacity}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.style.switcher.clear_opacity'))+\"\\n \")]),_vm._v(\" \"),_c('button',{staticClass:\"btn\",on:{\"click\":_vm.clearV1}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.style.switcher.clear_all'))+\"\\n \")])]),_vm._v(\" \"),_c('p',[_vm._v(_vm._s(_vm.$t('settings.theme_help_v2_1')))]),_vm._v(\" \"),_c('h4',[_vm._v(_vm._s(_vm.$t('settings.style.common_colors.main')))]),_vm._v(\" \"),_c('div',{staticClass:\"color-item\"},[_c('ColorInput',{attrs:{\"name\":\"bgColor\",\"label\":_vm.$t('settings.background')},model:{value:(_vm.bgColorLocal),callback:function ($$v) {_vm.bgColorLocal=$$v},expression:\"bgColorLocal\"}}),_vm._v(\" \"),_c('OpacityInput',{attrs:{\"name\":\"bgOpacity\",\"fallback\":_vm.previewTheme.opacity.bg || 1},model:{value:(_vm.bgOpacityLocal),callback:function ($$v) {_vm.bgOpacityLocal=$$v},expression:\"bgOpacityLocal\"}}),_vm._v(\" \"),_c('ColorInput',{attrs:{\"name\":\"textColor\",\"label\":_vm.$t('settings.text')},model:{value:(_vm.textColorLocal),callback:function ($$v) {_vm.textColorLocal=$$v},expression:\"textColorLocal\"}}),_vm._v(\" \"),_c('ContrastRatio',{attrs:{\"contrast\":_vm.previewContrast.bgText}}),_vm._v(\" \"),_c('ColorInput',{attrs:{\"name\":\"linkColor\",\"label\":_vm.$t('settings.links')},model:{value:(_vm.linkColorLocal),callback:function ($$v) {_vm.linkColorLocal=$$v},expression:\"linkColorLocal\"}}),_vm._v(\" \"),_c('ContrastRatio',{attrs:{\"contrast\":_vm.previewContrast.bgLink}})],1),_vm._v(\" \"),_c('div',{staticClass:\"color-item\"},[_c('ColorInput',{attrs:{\"name\":\"fgColor\",\"label\":_vm.$t('settings.foreground')},model:{value:(_vm.fgColorLocal),callback:function ($$v) {_vm.fgColorLocal=$$v},expression:\"fgColorLocal\"}}),_vm._v(\" \"),_c('ColorInput',{attrs:{\"name\":\"fgTextColor\",\"label\":_vm.$t('settings.text'),\"fallback\":_vm.previewTheme.colors.fgText},model:{value:(_vm.fgTextColorLocal),callback:function ($$v) {_vm.fgTextColorLocal=$$v},expression:\"fgTextColorLocal\"}}),_vm._v(\" \"),_c('ColorInput',{attrs:{\"name\":\"fgLinkColor\",\"label\":_vm.$t('settings.links'),\"fallback\":_vm.previewTheme.colors.fgLink},model:{value:(_vm.fgLinkColorLocal),callback:function ($$v) {_vm.fgLinkColorLocal=$$v},expression:\"fgLinkColorLocal\"}}),_vm._v(\" \"),_c('p',[_vm._v(_vm._s(_vm.$t('settings.style.common_colors.foreground_hint')))])],1),_vm._v(\" \"),_c('h4',[_vm._v(_vm._s(_vm.$t('settings.style.common_colors.rgbo')))]),_vm._v(\" \"),_c('div',{staticClass:\"color-item\"},[_c('ColorInput',{attrs:{\"name\":\"cRedColor\",\"label\":_vm.$t('settings.cRed')},model:{value:(_vm.cRedColorLocal),callback:function ($$v) {_vm.cRedColorLocal=$$v},expression:\"cRedColorLocal\"}}),_vm._v(\" \"),_c('ContrastRatio',{attrs:{\"contrast\":_vm.previewContrast.bgRed}}),_vm._v(\" \"),_c('ColorInput',{attrs:{\"name\":\"cBlueColor\",\"label\":_vm.$t('settings.cBlue')},model:{value:(_vm.cBlueColorLocal),callback:function ($$v) {_vm.cBlueColorLocal=$$v},expression:\"cBlueColorLocal\"}}),_vm._v(\" \"),_c('ContrastRatio',{attrs:{\"contrast\":_vm.previewContrast.bgBlue}})],1),_vm._v(\" \"),_c('div',{staticClass:\"color-item\"},[_c('ColorInput',{attrs:{\"name\":\"cGreenColor\",\"label\":_vm.$t('settings.cGreen')},model:{value:(_vm.cGreenColorLocal),callback:function ($$v) {_vm.cGreenColorLocal=$$v},expression:\"cGreenColorLocal\"}}),_vm._v(\" \"),_c('ContrastRatio',{attrs:{\"contrast\":_vm.previewContrast.bgGreen}}),_vm._v(\" \"),_c('ColorInput',{attrs:{\"name\":\"cOrangeColor\",\"label\":_vm.$t('settings.cOrange')},model:{value:(_vm.cOrangeColorLocal),callback:function ($$v) {_vm.cOrangeColorLocal=$$v},expression:\"cOrangeColorLocal\"}}),_vm._v(\" \"),_c('ContrastRatio',{attrs:{\"contrast\":_vm.previewContrast.bgOrange}})],1),_vm._v(\" \"),_c('p',[_vm._v(_vm._s(_vm.$t('settings.theme_help_v2_2')))])]),_vm._v(\" \"),_c('div',{staticClass:\"color-container\",attrs:{\"label\":_vm.$t('settings.style.advanced_colors._tab_label')}},[_c('div',{staticClass:\"tab-header\"},[_c('p',[_vm._v(_vm._s(_vm.$t('settings.theme_help')))]),_vm._v(\" \"),_c('button',{staticClass:\"btn\",on:{\"click\":_vm.clearOpacity}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.style.switcher.clear_opacity'))+\"\\n \")]),_vm._v(\" \"),_c('button',{staticClass:\"btn\",on:{\"click\":_vm.clearV1}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.style.switcher.clear_all'))+\"\\n \")])]),_vm._v(\" \"),_c('div',{staticClass:\"color-item\"},[_c('h4',[_vm._v(_vm._s(_vm.$t('settings.style.advanced_colors.alert')))]),_vm._v(\" \"),_c('ColorInput',{attrs:{\"name\":\"alertError\",\"label\":_vm.$t('settings.style.advanced_colors.alert_error'),\"fallback\":_vm.previewTheme.colors.alertError},model:{value:(_vm.alertErrorColorLocal),callback:function ($$v) {_vm.alertErrorColorLocal=$$v},expression:\"alertErrorColorLocal\"}}),_vm._v(\" \"),_c('ContrastRatio',{attrs:{\"contrast\":_vm.previewContrast.alertError}}),_vm._v(\" \"),_c('ColorInput',{attrs:{\"name\":\"alertWarning\",\"label\":_vm.$t('settings.style.advanced_colors.alert_warning'),\"fallback\":_vm.previewTheme.colors.alertWarning},model:{value:(_vm.alertWarningColorLocal),callback:function ($$v) {_vm.alertWarningColorLocal=$$v},expression:\"alertWarningColorLocal\"}}),_vm._v(\" \"),_c('ContrastRatio',{attrs:{\"contrast\":_vm.previewContrast.alertWarning}})],1),_vm._v(\" \"),_c('div',{staticClass:\"color-item\"},[_c('h4',[_vm._v(_vm._s(_vm.$t('settings.style.advanced_colors.badge')))]),_vm._v(\" \"),_c('ColorInput',{attrs:{\"name\":\"badgeNotification\",\"label\":_vm.$t('settings.style.advanced_colors.badge_notification'),\"fallback\":_vm.previewTheme.colors.badgeNotification},model:{value:(_vm.badgeNotificationColorLocal),callback:function ($$v) {_vm.badgeNotificationColorLocal=$$v},expression:\"badgeNotificationColorLocal\"}})],1),_vm._v(\" \"),_c('div',{staticClass:\"color-item\"},[_c('h4',[_vm._v(_vm._s(_vm.$t('settings.style.advanced_colors.panel_header')))]),_vm._v(\" \"),_c('ColorInput',{attrs:{\"name\":\"panelColor\",\"fallback\":_vm.fgColorLocal,\"label\":_vm.$t('settings.background')},model:{value:(_vm.panelColorLocal),callback:function ($$v) {_vm.panelColorLocal=$$v},expression:\"panelColorLocal\"}}),_vm._v(\" \"),_c('OpacityInput',{attrs:{\"name\":\"panelOpacity\",\"fallback\":_vm.previewTheme.opacity.panel || 1},model:{value:(_vm.panelOpacityLocal),callback:function ($$v) {_vm.panelOpacityLocal=$$v},expression:\"panelOpacityLocal\"}}),_vm._v(\" \"),_c('ColorInput',{attrs:{\"name\":\"panelTextColor\",\"fallback\":_vm.previewTheme.colors.panelText,\"label\":_vm.$t('settings.text')},model:{value:(_vm.panelTextColorLocal),callback:function ($$v) {_vm.panelTextColorLocal=$$v},expression:\"panelTextColorLocal\"}}),_vm._v(\" \"),_c('ContrastRatio',{attrs:{\"contrast\":_vm.previewContrast.panelText,\"large\":\"1\"}}),_vm._v(\" \"),_c('ColorInput',{attrs:{\"name\":\"panelLinkColor\",\"fallback\":_vm.previewTheme.colors.panelLink,\"label\":_vm.$t('settings.links')},model:{value:(_vm.panelLinkColorLocal),callback:function ($$v) {_vm.panelLinkColorLocal=$$v},expression:\"panelLinkColorLocal\"}}),_vm._v(\" \"),_c('ContrastRatio',{attrs:{\"contrast\":_vm.previewContrast.panelLink,\"large\":\"1\"}})],1),_vm._v(\" \"),_c('div',{staticClass:\"color-item\"},[_c('h4',[_vm._v(_vm._s(_vm.$t('settings.style.advanced_colors.top_bar')))]),_vm._v(\" \"),_c('ColorInput',{attrs:{\"name\":\"topBarColor\",\"fallback\":_vm.fgColorLocal,\"label\":_vm.$t('settings.background')},model:{value:(_vm.topBarColorLocal),callback:function ($$v) {_vm.topBarColorLocal=$$v},expression:\"topBarColorLocal\"}}),_vm._v(\" \"),_c('ColorInput',{attrs:{\"name\":\"topBarTextColor\",\"fallback\":_vm.previewTheme.colors.topBarText,\"label\":_vm.$t('settings.text')},model:{value:(_vm.topBarTextColorLocal),callback:function ($$v) {_vm.topBarTextColorLocal=$$v},expression:\"topBarTextColorLocal\"}}),_vm._v(\" \"),_c('ContrastRatio',{attrs:{\"contrast\":_vm.previewContrast.topBarText}}),_vm._v(\" \"),_c('ColorInput',{attrs:{\"name\":\"topBarLinkColor\",\"fallback\":_vm.previewTheme.colors.topBarLink,\"label\":_vm.$t('settings.links')},model:{value:(_vm.topBarLinkColorLocal),callback:function ($$v) {_vm.topBarLinkColorLocal=$$v},expression:\"topBarLinkColorLocal\"}}),_vm._v(\" \"),_c('ContrastRatio',{attrs:{\"contrast\":_vm.previewContrast.topBarLink}})],1),_vm._v(\" \"),_c('div',{staticClass:\"color-item\"},[_c('h4',[_vm._v(_vm._s(_vm.$t('settings.style.advanced_colors.inputs')))]),_vm._v(\" \"),_c('ColorInput',{attrs:{\"name\":\"inputColor\",\"fallback\":_vm.fgColorLocal,\"label\":_vm.$t('settings.background')},model:{value:(_vm.inputColorLocal),callback:function ($$v) {_vm.inputColorLocal=$$v},expression:\"inputColorLocal\"}}),_vm._v(\" \"),_c('OpacityInput',{attrs:{\"name\":\"inputOpacity\",\"fallback\":_vm.previewTheme.opacity.input || 1},model:{value:(_vm.inputOpacityLocal),callback:function ($$v) {_vm.inputOpacityLocal=$$v},expression:\"inputOpacityLocal\"}}),_vm._v(\" \"),_c('ColorInput',{attrs:{\"name\":\"inputTextColor\",\"fallback\":_vm.previewTheme.colors.inputText,\"label\":_vm.$t('settings.text')},model:{value:(_vm.inputTextColorLocal),callback:function ($$v) {_vm.inputTextColorLocal=$$v},expression:\"inputTextColorLocal\"}}),_vm._v(\" \"),_c('ContrastRatio',{attrs:{\"contrast\":_vm.previewContrast.inputText}})],1),_vm._v(\" \"),_c('div',{staticClass:\"color-item\"},[_c('h4',[_vm._v(_vm._s(_vm.$t('settings.style.advanced_colors.buttons')))]),_vm._v(\" \"),_c('ColorInput',{attrs:{\"name\":\"btnColor\",\"fallback\":_vm.fgColorLocal,\"label\":_vm.$t('settings.background')},model:{value:(_vm.btnColorLocal),callback:function ($$v) {_vm.btnColorLocal=$$v},expression:\"btnColorLocal\"}}),_vm._v(\" \"),_c('OpacityInput',{attrs:{\"name\":\"btnOpacity\",\"fallback\":_vm.previewTheme.opacity.btn || 1},model:{value:(_vm.btnOpacityLocal),callback:function ($$v) {_vm.btnOpacityLocal=$$v},expression:\"btnOpacityLocal\"}}),_vm._v(\" \"),_c('ColorInput',{attrs:{\"name\":\"btnTextColor\",\"fallback\":_vm.previewTheme.colors.btnText,\"label\":_vm.$t('settings.text')},model:{value:(_vm.btnTextColorLocal),callback:function ($$v) {_vm.btnTextColorLocal=$$v},expression:\"btnTextColorLocal\"}}),_vm._v(\" \"),_c('ContrastRatio',{attrs:{\"contrast\":_vm.previewContrast.btnText}})],1),_vm._v(\" \"),_c('div',{staticClass:\"color-item\"},[_c('h4',[_vm._v(_vm._s(_vm.$t('settings.style.advanced_colors.borders')))]),_vm._v(\" \"),_c('ColorInput',{attrs:{\"name\":\"borderColor\",\"fallback\":_vm.previewTheme.colors.border,\"label\":_vm.$t('settings.style.common.color')},model:{value:(_vm.borderColorLocal),callback:function ($$v) {_vm.borderColorLocal=$$v},expression:\"borderColorLocal\"}}),_vm._v(\" \"),_c('OpacityInput',{attrs:{\"name\":\"borderOpacity\",\"fallback\":_vm.previewTheme.opacity.border || 1},model:{value:(_vm.borderOpacityLocal),callback:function ($$v) {_vm.borderOpacityLocal=$$v},expression:\"borderOpacityLocal\"}})],1),_vm._v(\" \"),_c('div',{staticClass:\"color-item\"},[_c('h4',[_vm._v(_vm._s(_vm.$t('settings.style.advanced_colors.faint_text')))]),_vm._v(\" \"),_c('ColorInput',{attrs:{\"name\":\"faintColor\",\"fallback\":_vm.previewTheme.colors.faint || 1,\"label\":_vm.$t('settings.text')},model:{value:(_vm.faintColorLocal),callback:function ($$v) {_vm.faintColorLocal=$$v},expression:\"faintColorLocal\"}}),_vm._v(\" \"),_c('ColorInput',{attrs:{\"name\":\"faintLinkColor\",\"fallback\":_vm.previewTheme.colors.faintLink,\"label\":_vm.$t('settings.links')},model:{value:(_vm.faintLinkColorLocal),callback:function ($$v) {_vm.faintLinkColorLocal=$$v},expression:\"faintLinkColorLocal\"}}),_vm._v(\" \"),_c('ColorInput',{attrs:{\"name\":\"panelFaintColor\",\"fallback\":_vm.previewTheme.colors.panelFaint,\"label\":_vm.$t('settings.style.advanced_colors.panel_header')},model:{value:(_vm.panelFaintColorLocal),callback:function ($$v) {_vm.panelFaintColorLocal=$$v},expression:\"panelFaintColorLocal\"}}),_vm._v(\" \"),_c('OpacityInput',{attrs:{\"name\":\"faintOpacity\",\"fallback\":_vm.previewTheme.opacity.faint || 0.5},model:{value:(_vm.faintOpacityLocal),callback:function ($$v) {_vm.faintOpacityLocal=$$v},expression:\"faintOpacityLocal\"}})],1)]),_vm._v(\" \"),_c('div',{staticClass:\"radius-container\",attrs:{\"label\":_vm.$t('settings.style.radii._tab_label')}},[_c('div',{staticClass:\"tab-header\"},[_c('p',[_vm._v(_vm._s(_vm.$t('settings.radii_help')))]),_vm._v(\" \"),_c('button',{staticClass:\"btn\",on:{\"click\":_vm.clearRoundness}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.style.switcher.clear_all'))+\"\\n \")])]),_vm._v(\" \"),_c('RangeInput',{attrs:{\"name\":\"btnRadius\",\"label\":_vm.$t('settings.btnRadius'),\"fallback\":_vm.previewTheme.radii.btn,\"max\":\"16\",\"hard-min\":\"0\"},model:{value:(_vm.btnRadiusLocal),callback:function ($$v) {_vm.btnRadiusLocal=$$v},expression:\"btnRadiusLocal\"}}),_vm._v(\" \"),_c('RangeInput',{attrs:{\"name\":\"inputRadius\",\"label\":_vm.$t('settings.inputRadius'),\"fallback\":_vm.previewTheme.radii.input,\"max\":\"9\",\"hard-min\":\"0\"},model:{value:(_vm.inputRadiusLocal),callback:function ($$v) {_vm.inputRadiusLocal=$$v},expression:\"inputRadiusLocal\"}}),_vm._v(\" \"),_c('RangeInput',{attrs:{\"name\":\"checkboxRadius\",\"label\":_vm.$t('settings.checkboxRadius'),\"fallback\":_vm.previewTheme.radii.checkbox,\"max\":\"16\",\"hard-min\":\"0\"},model:{value:(_vm.checkboxRadiusLocal),callback:function ($$v) {_vm.checkboxRadiusLocal=$$v},expression:\"checkboxRadiusLocal\"}}),_vm._v(\" \"),_c('RangeInput',{attrs:{\"name\":\"panelRadius\",\"label\":_vm.$t('settings.panelRadius'),\"fallback\":_vm.previewTheme.radii.panel,\"max\":\"50\",\"hard-min\":\"0\"},model:{value:(_vm.panelRadiusLocal),callback:function ($$v) {_vm.panelRadiusLocal=$$v},expression:\"panelRadiusLocal\"}}),_vm._v(\" \"),_c('RangeInput',{attrs:{\"name\":\"avatarRadius\",\"label\":_vm.$t('settings.avatarRadius'),\"fallback\":_vm.previewTheme.radii.avatar,\"max\":\"28\",\"hard-min\":\"0\"},model:{value:(_vm.avatarRadiusLocal),callback:function ($$v) {_vm.avatarRadiusLocal=$$v},expression:\"avatarRadiusLocal\"}}),_vm._v(\" \"),_c('RangeInput',{attrs:{\"name\":\"avatarAltRadius\",\"label\":_vm.$t('settings.avatarAltRadius'),\"fallback\":_vm.previewTheme.radii.avatarAlt,\"max\":\"28\",\"hard-min\":\"0\"},model:{value:(_vm.avatarAltRadiusLocal),callback:function ($$v) {_vm.avatarAltRadiusLocal=$$v},expression:\"avatarAltRadiusLocal\"}}),_vm._v(\" \"),_c('RangeInput',{attrs:{\"name\":\"attachmentRadius\",\"label\":_vm.$t('settings.attachmentRadius'),\"fallback\":_vm.previewTheme.radii.attachment,\"max\":\"50\",\"hard-min\":\"0\"},model:{value:(_vm.attachmentRadiusLocal),callback:function ($$v) {_vm.attachmentRadiusLocal=$$v},expression:\"attachmentRadiusLocal\"}}),_vm._v(\" \"),_c('RangeInput',{attrs:{\"name\":\"tooltipRadius\",\"label\":_vm.$t('settings.tooltipRadius'),\"fallback\":_vm.previewTheme.radii.tooltip,\"max\":\"50\",\"hard-min\":\"0\"},model:{value:(_vm.tooltipRadiusLocal),callback:function ($$v) {_vm.tooltipRadiusLocal=$$v},expression:\"tooltipRadiusLocal\"}})],1),_vm._v(\" \"),_c('div',{staticClass:\"shadow-container\",attrs:{\"label\":_vm.$t('settings.style.shadows._tab_label')}},[_c('div',{staticClass:\"tab-header shadow-selector\"},[_c('div',{staticClass:\"select-container\"},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.style.shadows.component'))+\"\\n \"),_c('label',{staticClass:\"select\",attrs:{\"for\":\"shadow-switcher\"}},[_c('select',{directives:[{name:\"model\",rawName:\"v-model\",value:(_vm.shadowSelected),expression:\"shadowSelected\"}],staticClass:\"shadow-switcher\",attrs:{\"id\":\"shadow-switcher\"},on:{\"change\":function($event){var $$selectedVal = Array.prototype.filter.call($event.target.options,function(o){return o.selected}).map(function(o){var val = \"_value\" in o ? o._value : o.value;return val}); _vm.shadowSelected=$event.target.multiple ? $$selectedVal : $$selectedVal[0]}}},_vm._l((_vm.shadowsAvailable),function(shadow){return _c('option',{key:shadow,domProps:{\"value\":shadow}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.style.shadows.components.' + shadow))+\"\\n \")])}),0),_vm._v(\" \"),_c('i',{staticClass:\"icon-down-open\"})])]),_vm._v(\" \"),_c('div',{staticClass:\"override\"},[_c('label',{staticClass:\"label\",attrs:{\"for\":\"override\"}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.style.shadows.override'))+\"\\n \")]),_vm._v(\" \"),_c('input',{directives:[{name:\"model\",rawName:\"v-model\",value:(_vm.currentShadowOverriden),expression:\"currentShadowOverriden\"}],staticClass:\"input-override\",attrs:{\"id\":\"override\",\"name\":\"override\",\"type\":\"checkbox\"},domProps:{\"checked\":Array.isArray(_vm.currentShadowOverriden)?_vm._i(_vm.currentShadowOverriden,null)>-1:(_vm.currentShadowOverriden)},on:{\"change\":function($event){var $$a=_vm.currentShadowOverriden,$$el=$event.target,$$c=$$el.checked?(true):(false);if(Array.isArray($$a)){var $$v=null,$$i=_vm._i($$a,$$v);if($$el.checked){$$i<0&&(_vm.currentShadowOverriden=$$a.concat([$$v]))}else{$$i>-1&&(_vm.currentShadowOverriden=$$a.slice(0,$$i).concat($$a.slice($$i+1)))}}else{_vm.currentShadowOverriden=$$c}}}}),_vm._v(\" \"),_c('label',{staticClass:\"checkbox-label\",attrs:{\"for\":\"override\"}})]),_vm._v(\" \"),_c('button',{staticClass:\"btn\",on:{\"click\":_vm.clearShadows}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.style.switcher.clear_all'))+\"\\n \")])]),_vm._v(\" \"),_c('shadow-control',{attrs:{\"ready\":!!_vm.currentShadowFallback,\"fallback\":_vm.currentShadowFallback},model:{value:(_vm.currentShadow),callback:function ($$v) {_vm.currentShadow=$$v},expression:\"currentShadow\"}}),_vm._v(\" \"),(_vm.shadowSelected === 'avatar' || _vm.shadowSelected === 'avatarStatus')?_c('div',[_c('i18n',{attrs:{\"path\":\"settings.style.shadows.filter_hint.always_drop_shadow\",\"tag\":\"p\"}},[_c('code',[_vm._v(\"filter: drop-shadow()\")])]),_vm._v(\" \"),_c('p',[_vm._v(_vm._s(_vm.$t('settings.style.shadows.filter_hint.avatar_inset')))]),_vm._v(\" \"),_c('i18n',{attrs:{\"path\":\"settings.style.shadows.filter_hint.drop_shadow_syntax\",\"tag\":\"p\"}},[_c('code',[_vm._v(\"drop-shadow\")]),_vm._v(\" \"),_c('code',[_vm._v(\"spread-radius\")]),_vm._v(\" \"),_c('code',[_vm._v(\"inset\")])]),_vm._v(\" \"),_c('i18n',{attrs:{\"path\":\"settings.style.shadows.filter_hint.inset_classic\",\"tag\":\"p\"}},[_c('code',[_vm._v(\"box-shadow\")])]),_vm._v(\" \"),_c('p',[_vm._v(_vm._s(_vm.$t('settings.style.shadows.filter_hint.spread_zero')))])],1):_vm._e()],1),_vm._v(\" \"),_c('div',{staticClass:\"fonts-container\",attrs:{\"label\":_vm.$t('settings.style.fonts._tab_label')}},[_c('div',{staticClass:\"tab-header\"},[_c('p',[_vm._v(_vm._s(_vm.$t('settings.style.fonts.help')))]),_vm._v(\" \"),_c('button',{staticClass:\"btn\",on:{\"click\":_vm.clearFonts}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.style.switcher.clear_all'))+\"\\n \")])]),_vm._v(\" \"),_c('FontControl',{attrs:{\"name\":\"ui\",\"label\":_vm.$t('settings.style.fonts.components.interface'),\"fallback\":_vm.previewTheme.fonts.interface,\"no-inherit\":\"1\"},model:{value:(_vm.fontsLocal.interface),callback:function ($$v) {_vm.$set(_vm.fontsLocal, \"interface\", $$v)},expression:\"fontsLocal.interface\"}}),_vm._v(\" \"),_c('FontControl',{attrs:{\"name\":\"input\",\"label\":_vm.$t('settings.style.fonts.components.input'),\"fallback\":_vm.previewTheme.fonts.input},model:{value:(_vm.fontsLocal.input),callback:function ($$v) {_vm.$set(_vm.fontsLocal, \"input\", $$v)},expression:\"fontsLocal.input\"}}),_vm._v(\" \"),_c('FontControl',{attrs:{\"name\":\"post\",\"label\":_vm.$t('settings.style.fonts.components.post'),\"fallback\":_vm.previewTheme.fonts.post},model:{value:(_vm.fontsLocal.post),callback:function ($$v) {_vm.$set(_vm.fontsLocal, \"post\", $$v)},expression:\"fontsLocal.post\"}}),_vm._v(\" \"),_c('FontControl',{attrs:{\"name\":\"postCode\",\"label\":_vm.$t('settings.style.fonts.components.postCode'),\"fallback\":_vm.previewTheme.fonts.postCode},model:{value:(_vm.fontsLocal.postCode),callback:function ($$v) {_vm.$set(_vm.fontsLocal, \"postCode\", $$v)},expression:\"fontsLocal.postCode\"}})],1)])],1),_vm._v(\" \"),_c('div',{staticClass:\"apply-container\"},[_c('button',{staticClass:\"btn submit\",attrs:{\"disabled\":!_vm.themeValid},on:{\"click\":_vm.setCustomTheme}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('general.apply'))+\"\\n \")]),_vm._v(\" \"),_c('button',{staticClass:\"btn\",on:{\"click\":_vm.clearAll}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.style.switcher.reset'))+\"\\n \")])])],1)}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',[_c('label',{attrs:{\"for\":\"interface-language-switcher\"}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.interfaceLanguage'))+\"\\n \")]),_vm._v(\" \"),_c('label',{staticClass:\"select\",attrs:{\"for\":\"interface-language-switcher\"}},[_c('select',{directives:[{name:\"model\",rawName:\"v-model\",value:(_vm.language),expression:\"language\"}],attrs:{\"id\":\"interface-language-switcher\"},on:{\"change\":function($event){var $$selectedVal = Array.prototype.filter.call($event.target.options,function(o){return o.selected}).map(function(o){var val = \"_value\" in o ? o._value : o.value;return val}); _vm.language=$event.target.multiple ? $$selectedVal : $$selectedVal[0]}}},_vm._l((_vm.languageCodes),function(langCode,i){return _c('option',{key:langCode,domProps:{\"value\":langCode}},[_vm._v(\"\\n \"+_vm._s(_vm.languageNames[i])+\"\\n \")])}),0),_vm._v(\" \"),_c('i',{staticClass:\"icon-down-open\"})])])}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:\"settings panel panel-default\"},[_c('div',{staticClass:\"panel-heading\"},[_c('div',{staticClass:\"title\"},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.settings'))+\"\\n \")]),_vm._v(\" \"),_c('transition',{attrs:{\"name\":\"fade\"}},[(_vm.currentSaveStateNotice)?[(_vm.currentSaveStateNotice.error)?_c('div',{staticClass:\"alert error\",on:{\"click\":function($event){$event.preventDefault();}}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.saving_err'))+\"\\n \")]):_vm._e(),_vm._v(\" \"),(!_vm.currentSaveStateNotice.error)?_c('div',{staticClass:\"alert transparent\",on:{\"click\":function($event){$event.preventDefault();}}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.saving_ok'))+\"\\n \")]):_vm._e()]:_vm._e()],2)],1),_vm._v(\" \"),_c('div',{staticClass:\"panel-body\"},[_c('keep-alive',[_c('tab-switcher',[_c('div',{attrs:{\"label\":_vm.$t('settings.general')}},[_c('div',{staticClass:\"setting-item\"},[_c('h2',[_vm._v(_vm._s(_vm.$t('settings.interface')))]),_vm._v(\" \"),_c('ul',{staticClass:\"setting-list\"},[_c('li',[_c('interface-language-switcher')],1),_vm._v(\" \"),(_vm.instanceSpecificPanelPresent)?_c('li',[_c('Checkbox',{model:{value:(_vm.hideISP),callback:function ($$v) {_vm.hideISP=$$v},expression:\"hideISP\"}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.hide_isp'))+\"\\n \")])],1):_vm._e()])]),_vm._v(\" \"),_c('div',{staticClass:\"setting-item\"},[_c('h2',[_vm._v(_vm._s(_vm.$t('nav.timeline')))]),_vm._v(\" \"),_c('ul',{staticClass:\"setting-list\"},[_c('li',[_c('Checkbox',{model:{value:(_vm.hideMutedPosts),callback:function ($$v) {_vm.hideMutedPosts=$$v},expression:\"hideMutedPosts\"}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.hide_muted_posts'))+\" \"+_vm._s(_vm.$t('settings.instance_default', { value: _vm.hideMutedPostsLocalizedValue }))+\"\\n \")])],1),_vm._v(\" \"),_c('li',[_c('Checkbox',{model:{value:(_vm.collapseMessageWithSubject),callback:function ($$v) {_vm.collapseMessageWithSubject=$$v},expression:\"collapseMessageWithSubject\"}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.collapse_subject'))+\" \"+_vm._s(_vm.$t('settings.instance_default', { value: _vm.collapseMessageWithSubjectLocalizedValue }))+\"\\n \")])],1),_vm._v(\" \"),_c('li',[_c('Checkbox',{model:{value:(_vm.streaming),callback:function ($$v) {_vm.streaming=$$v},expression:\"streaming\"}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.streaming'))+\"\\n \")]),_vm._v(\" \"),_c('ul',{staticClass:\"setting-list suboptions\",class:[{disabled: !_vm.streaming}]},[_c('li',[_c('Checkbox',{attrs:{\"disabled\":!_vm.streaming},model:{value:(_vm.pauseOnUnfocused),callback:function ($$v) {_vm.pauseOnUnfocused=$$v},expression:\"pauseOnUnfocused\"}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.pause_on_unfocused'))+\"\\n \")])],1)])],1),_vm._v(\" \"),_c('li',[_c('Checkbox',{model:{value:(_vm.autoLoad),callback:function ($$v) {_vm.autoLoad=$$v},expression:\"autoLoad\"}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.autoload'))+\"\\n \")])],1),_vm._v(\" \"),_c('li',[_c('Checkbox',{model:{value:(_vm.hoverPreview),callback:function ($$v) {_vm.hoverPreview=$$v},expression:\"hoverPreview\"}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.reply_link_preview'))+\"\\n \")])],1)])]),_vm._v(\" \"),_c('div',{staticClass:\"setting-item\"},[_c('h2',[_vm._v(_vm._s(_vm.$t('settings.composing')))]),_vm._v(\" \"),_c('ul',{staticClass:\"setting-list\"},[_c('li',[_c('Checkbox',{model:{value:(_vm.scopeCopy),callback:function ($$v) {_vm.scopeCopy=$$v},expression:\"scopeCopy\"}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.scope_copy'))+\" \"+_vm._s(_vm.$t('settings.instance_default', { value: _vm.scopeCopyLocalizedValue }))+\"\\n \")])],1),_vm._v(\" \"),_c('li',[_c('Checkbox',{model:{value:(_vm.alwaysShowSubjectInput),callback:function ($$v) {_vm.alwaysShowSubjectInput=$$v},expression:\"alwaysShowSubjectInput\"}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.subject_input_always_show'))+\" \"+_vm._s(_vm.$t('settings.instance_default', { value: _vm.alwaysShowSubjectInputLocalizedValue }))+\"\\n \")])],1),_vm._v(\" \"),_c('li',[_c('div',[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.subject_line_behavior'))+\"\\n \"),_c('label',{staticClass:\"select\",attrs:{\"for\":\"subjectLineBehavior\"}},[_c('select',{directives:[{name:\"model\",rawName:\"v-model\",value:(_vm.subjectLineBehavior),expression:\"subjectLineBehavior\"}],attrs:{\"id\":\"subjectLineBehavior\"},on:{\"change\":function($event){var $$selectedVal = Array.prototype.filter.call($event.target.options,function(o){return o.selected}).map(function(o){var val = \"_value\" in o ? o._value : o.value;return val}); _vm.subjectLineBehavior=$event.target.multiple ? $$selectedVal : $$selectedVal[0]}}},[_c('option',{attrs:{\"value\":\"email\"}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.subject_line_email'))+\"\\n \"+_vm._s(_vm.subjectLineBehaviorDefaultValue == 'email' ? _vm.$t('settings.instance_default_simple') : '')+\"\\n \")]),_vm._v(\" \"),_c('option',{attrs:{\"value\":\"masto\"}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.subject_line_mastodon'))+\"\\n \"+_vm._s(_vm.subjectLineBehaviorDefaultValue == 'mastodon' ? _vm.$t('settings.instance_default_simple') : '')+\"\\n \")]),_vm._v(\" \"),_c('option',{attrs:{\"value\":\"noop\"}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.subject_line_noop'))+\"\\n \"+_vm._s(_vm.subjectLineBehaviorDefaultValue == 'noop' ? _vm.$t('settings.instance_default_simple') : '')+\"\\n \")])]),_vm._v(\" \"),_c('i',{staticClass:\"icon-down-open\"})])])]),_vm._v(\" \"),(_vm.postFormats.length > 0)?_c('li',[_c('div',[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.post_status_content_type'))+\"\\n \"),_c('label',{staticClass:\"select\",attrs:{\"for\":\"postContentType\"}},[_c('select',{directives:[{name:\"model\",rawName:\"v-model\",value:(_vm.postContentType),expression:\"postContentType\"}],attrs:{\"id\":\"postContentType\"},on:{\"change\":function($event){var $$selectedVal = Array.prototype.filter.call($event.target.options,function(o){return o.selected}).map(function(o){var val = \"_value\" in o ? o._value : o.value;return val}); _vm.postContentType=$event.target.multiple ? $$selectedVal : $$selectedVal[0]}}},_vm._l((_vm.postFormats),function(postFormat){return _c('option',{key:postFormat,domProps:{\"value\":postFormat}},[_vm._v(\"\\n \"+_vm._s(_vm.$t((\"post_status.content_type[\\\"\" + postFormat + \"\\\"]\")))+\"\\n \"+_vm._s(_vm.postContentTypeDefaultValue === postFormat ? _vm.$t('settings.instance_default_simple') : '')+\"\\n \")])}),0),_vm._v(\" \"),_c('i',{staticClass:\"icon-down-open\"})])])]):_vm._e(),_vm._v(\" \"),_c('li',[_c('Checkbox',{model:{value:(_vm.minimalScopesMode),callback:function ($$v) {_vm.minimalScopesMode=$$v},expression:\"minimalScopesMode\"}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.minimal_scopes_mode'))+\" \"+_vm._s(_vm.$t('settings.instance_default', { value: _vm.minimalScopesModeLocalizedValue }))+\"\\n \")])],1),_vm._v(\" \"),_c('li',[_c('Checkbox',{model:{value:(_vm.autohideFloatingPostButton),callback:function ($$v) {_vm.autohideFloatingPostButton=$$v},expression:\"autohideFloatingPostButton\"}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.autohide_floating_post_button'))+\"\\n \")])],1),_vm._v(\" \"),_c('li',[_c('Checkbox',{model:{value:(_vm.padEmoji),callback:function ($$v) {_vm.padEmoji=$$v},expression:\"padEmoji\"}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.pad_emoji'))+\"\\n \")])],1)])]),_vm._v(\" \"),_c('div',{staticClass:\"setting-item\"},[_c('h2',[_vm._v(_vm._s(_vm.$t('settings.attachments')))]),_vm._v(\" \"),_c('ul',{staticClass:\"setting-list\"},[_c('li',[_c('Checkbox',{model:{value:(_vm.hideAttachments),callback:function ($$v) {_vm.hideAttachments=$$v},expression:\"hideAttachments\"}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.hide_attachments_in_tl'))+\"\\n \")])],1),_vm._v(\" \"),_c('li',[_c('Checkbox',{model:{value:(_vm.hideAttachmentsInConv),callback:function ($$v) {_vm.hideAttachmentsInConv=$$v},expression:\"hideAttachmentsInConv\"}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.hide_attachments_in_convo'))+\"\\n \")])],1),_vm._v(\" \"),_c('li',[_c('label',{attrs:{\"for\":\"maxThumbnails\"}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.max_thumbnails'))+\"\\n \")]),_vm._v(\" \"),_c('input',{directives:[{name:\"model\",rawName:\"v-model.number\",value:(_vm.maxThumbnails),expression:\"maxThumbnails\",modifiers:{\"number\":true}}],staticClass:\"number-input\",attrs:{\"id\":\"maxThumbnails\",\"type\":\"number\",\"min\":\"0\",\"step\":\"1\"},domProps:{\"value\":(_vm.maxThumbnails)},on:{\"input\":function($event){if($event.target.composing){ return; }_vm.maxThumbnails=_vm._n($event.target.value)},\"blur\":function($event){_vm.$forceUpdate()}}})]),_vm._v(\" \"),_c('li',[_c('Checkbox',{model:{value:(_vm.hideNsfw),callback:function ($$v) {_vm.hideNsfw=$$v},expression:\"hideNsfw\"}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.nsfw_clickthrough'))+\"\\n \")])],1),_vm._v(\" \"),_c('ul',{staticClass:\"setting-list suboptions\"},[_c('li',[_c('Checkbox',{attrs:{\"disabled\":!_vm.hideNsfw},model:{value:(_vm.preloadImage),callback:function ($$v) {_vm.preloadImage=$$v},expression:\"preloadImage\"}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.preload_images'))+\"\\n \")])],1),_vm._v(\" \"),_c('li',[_c('Checkbox',{attrs:{\"disabled\":!_vm.hideNsfw},model:{value:(_vm.useOneClickNsfw),callback:function ($$v) {_vm.useOneClickNsfw=$$v},expression:\"useOneClickNsfw\"}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.use_one_click_nsfw'))+\"\\n \")])],1)]),_vm._v(\" \"),_c('li',[_c('Checkbox',{model:{value:(_vm.stopGifs),callback:function ($$v) {_vm.stopGifs=$$v},expression:\"stopGifs\"}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.stop_gifs'))+\"\\n \")])],1),_vm._v(\" \"),_c('li',[_c('Checkbox',{model:{value:(_vm.loopVideo),callback:function ($$v) {_vm.loopVideo=$$v},expression:\"loopVideo\"}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.loop_video'))+\"\\n \")]),_vm._v(\" \"),_c('ul',{staticClass:\"setting-list suboptions\",class:[{disabled: !_vm.streaming}]},[_c('li',[_c('Checkbox',{attrs:{\"disabled\":!_vm.loopVideo || !_vm.loopSilentAvailable},model:{value:(_vm.loopVideoSilentOnly),callback:function ($$v) {_vm.loopVideoSilentOnly=$$v},expression:\"loopVideoSilentOnly\"}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.loop_video_silent_only'))+\"\\n \")]),_vm._v(\" \"),(!_vm.loopSilentAvailable)?_c('div',{staticClass:\"unavailable\"},[_c('i',{staticClass:\"icon-globe\"}),_vm._v(\"! \"+_vm._s(_vm.$t('settings.limited_availability'))+\"\\n \")]):_vm._e()],1)])],1),_vm._v(\" \"),_c('li',[_c('Checkbox',{model:{value:(_vm.playVideosInModal),callback:function ($$v) {_vm.playVideosInModal=$$v},expression:\"playVideosInModal\"}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.play_videos_in_modal'))+\"\\n \")])],1),_vm._v(\" \"),_c('li',[_c('Checkbox',{model:{value:(_vm.useContainFit),callback:function ($$v) {_vm.useContainFit=$$v},expression:\"useContainFit\"}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.use_contain_fit'))+\"\\n \")])],1)])]),_vm._v(\" \"),_c('div',{staticClass:\"setting-item\"},[_c('h2',[_vm._v(_vm._s(_vm.$t('settings.notifications')))]),_vm._v(\" \"),_c('ul',{staticClass:\"setting-list\"},[_c('li',[_c('Checkbox',{model:{value:(_vm.webPushNotifications),callback:function ($$v) {_vm.webPushNotifications=$$v},expression:\"webPushNotifications\"}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.enable_web_push_notifications'))+\"\\n \")])],1)])])]),_vm._v(\" \"),_c('div',{attrs:{\"label\":_vm.$t('settings.theme')}},[_c('div',{staticClass:\"setting-item\"},[_c('style-switcher')],1)]),_vm._v(\" \"),_c('div',{attrs:{\"label\":_vm.$t('settings.filtering')}},[_c('div',{staticClass:\"setting-item\"},[_c('div',{staticClass:\"select-multiple\"},[_c('span',{staticClass:\"label\"},[_vm._v(_vm._s(_vm.$t('settings.notification_visibility')))]),_vm._v(\" \"),_c('ul',{staticClass:\"option-list\"},[_c('li',[_c('Checkbox',{model:{value:(_vm.notificationVisibility.likes),callback:function ($$v) {_vm.$set(_vm.notificationVisibility, \"likes\", $$v)},expression:\"notificationVisibility.likes\"}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.notification_visibility_likes'))+\"\\n \")])],1),_vm._v(\" \"),_c('li',[_c('Checkbox',{model:{value:(_vm.notificationVisibility.repeats),callback:function ($$v) {_vm.$set(_vm.notificationVisibility, \"repeats\", $$v)},expression:\"notificationVisibility.repeats\"}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.notification_visibility_repeats'))+\"\\n \")])],1),_vm._v(\" \"),_c('li',[_c('Checkbox',{model:{value:(_vm.notificationVisibility.follows),callback:function ($$v) {_vm.$set(_vm.notificationVisibility, \"follows\", $$v)},expression:\"notificationVisibility.follows\"}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.notification_visibility_follows'))+\"\\n \")])],1),_vm._v(\" \"),_c('li',[_c('Checkbox',{model:{value:(_vm.notificationVisibility.mentions),callback:function ($$v) {_vm.$set(_vm.notificationVisibility, \"mentions\", $$v)},expression:\"notificationVisibility.mentions\"}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.notification_visibility_mentions'))+\"\\n \")])],1)])]),_vm._v(\" \"),_c('div',[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.replies_in_timeline'))+\"\\n \"),_c('label',{staticClass:\"select\",attrs:{\"for\":\"replyVisibility\"}},[_c('select',{directives:[{name:\"model\",rawName:\"v-model\",value:(_vm.replyVisibility),expression:\"replyVisibility\"}],attrs:{\"id\":\"replyVisibility\"},on:{\"change\":function($event){var $$selectedVal = Array.prototype.filter.call($event.target.options,function(o){return o.selected}).map(function(o){var val = \"_value\" in o ? o._value : o.value;return val}); _vm.replyVisibility=$event.target.multiple ? $$selectedVal : $$selectedVal[0]}}},[_c('option',{attrs:{\"value\":\"all\",\"selected\":\"\"}},[_vm._v(_vm._s(_vm.$t('settings.reply_visibility_all')))]),_vm._v(\" \"),_c('option',{attrs:{\"value\":\"following\"}},[_vm._v(_vm._s(_vm.$t('settings.reply_visibility_following')))]),_vm._v(\" \"),_c('option',{attrs:{\"value\":\"self\"}},[_vm._v(_vm._s(_vm.$t('settings.reply_visibility_self')))])]),_vm._v(\" \"),_c('i',{staticClass:\"icon-down-open\"})])]),_vm._v(\" \"),_c('div',[_c('Checkbox',{model:{value:(_vm.hidePostStats),callback:function ($$v) {_vm.hidePostStats=$$v},expression:\"hidePostStats\"}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.hide_post_stats'))+\" \"+_vm._s(_vm.$t('settings.instance_default', { value: _vm.hidePostStatsLocalizedValue }))+\"\\n \")])],1),_vm._v(\" \"),_c('div',[_c('Checkbox',{model:{value:(_vm.hideUserStats),callback:function ($$v) {_vm.hideUserStats=$$v},expression:\"hideUserStats\"}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.hide_user_stats'))+\" \"+_vm._s(_vm.$t('settings.instance_default', { value: _vm.hideUserStatsLocalizedValue }))+\"\\n \")])],1)]),_vm._v(\" \"),_c('div',{staticClass:\"setting-item\"},[_c('div',[_c('p',[_vm._v(_vm._s(_vm.$t('settings.filtering_explanation')))]),_vm._v(\" \"),_c('textarea',{directives:[{name:\"model\",rawName:\"v-model\",value:(_vm.muteWordsString),expression:\"muteWordsString\"}],attrs:{\"id\":\"muteWords\"},domProps:{\"value\":(_vm.muteWordsString)},on:{\"input\":function($event){if($event.target.composing){ return; }_vm.muteWordsString=$event.target.value}}})]),_vm._v(\" \"),_c('div',[_c('Checkbox',{model:{value:(_vm.hideFilteredStatuses),callback:function ($$v) {_vm.hideFilteredStatuses=$$v},expression:\"hideFilteredStatuses\"}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.hide_filtered_statuses'))+\" \"+_vm._s(_vm.$t('settings.instance_default', { value: _vm.hideFilteredStatusesLocalizedValue }))+\"\\n \")])],1)])]),_vm._v(\" \"),_c('div',{attrs:{\"label\":_vm.$t('settings.version.title')}},[_c('div',{staticClass:\"setting-item\"},[_c('ul',{staticClass:\"setting-list\"},[_c('li',[_c('p',[_vm._v(_vm._s(_vm.$t('settings.version.backend_version')))]),_vm._v(\" \"),_c('ul',{staticClass:\"option-list\"},[_c('li',[_c('a',{attrs:{\"href\":_vm.backendVersionLink,\"target\":\"_blank\"}},[_vm._v(_vm._s(_vm.backendVersion))])])])]),_vm._v(\" \"),_c('li',[_c('p',[_vm._v(_vm._s(_vm.$t('settings.version.frontend_version')))]),_vm._v(\" \"),_c('ul',{staticClass:\"option-list\"},[_c('li',[_c('a',{attrs:{\"href\":_vm.frontendVersionLink,\"target\":\"_blank\"}},[_vm._v(_vm._s(_vm.frontendVersion))])])])])])])])])],1)],1)])}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:\"settings panel panel-default\"},[_c('div',{staticClass:\"panel-heading\"},[_vm._v(\"\\n \"+_vm._s(_vm.$t('registration.registration'))+\"\\n \")]),_vm._v(\" \"),_c('div',{staticClass:\"panel-body\"},[_c('form',{staticClass:\"registration-form\",on:{\"submit\":function($event){$event.preventDefault();_vm.submit(_vm.user)}}},[_c('div',{staticClass:\"container\"},[_c('div',{staticClass:\"text-fields\"},[_c('div',{staticClass:\"form-group\",class:{ 'form-group--error': _vm.$v.user.username.$error }},[_c('label',{staticClass:\"form--label\",attrs:{\"for\":\"sign-up-username\"}},[_vm._v(_vm._s(_vm.$t('login.username')))]),_vm._v(\" \"),_c('input',{directives:[{name:\"model\",rawName:\"v-model.trim\",value:(_vm.$v.user.username.$model),expression:\"$v.user.username.$model\",modifiers:{\"trim\":true}}],staticClass:\"form-control\",attrs:{\"id\":\"sign-up-username\",\"disabled\":_vm.isPending,\"placeholder\":_vm.$t('registration.username_placeholder')},domProps:{\"value\":(_vm.$v.user.username.$model)},on:{\"input\":function($event){if($event.target.composing){ return; }_vm.$set(_vm.$v.user.username, \"$model\", $event.target.value.trim())},\"blur\":function($event){_vm.$forceUpdate()}}})]),_vm._v(\" \"),(_vm.$v.user.username.$dirty)?_c('div',{staticClass:\"form-error\"},[_c('ul',[(!_vm.$v.user.username.required)?_c('li',[_c('span',[_vm._v(_vm._s(_vm.$t('registration.validations.username_required')))])]):_vm._e()])]):_vm._e(),_vm._v(\" \"),_c('div',{staticClass:\"form-group\",class:{ 'form-group--error': _vm.$v.user.fullname.$error }},[_c('label',{staticClass:\"form--label\",attrs:{\"for\":\"sign-up-fullname\"}},[_vm._v(_vm._s(_vm.$t('registration.fullname')))]),_vm._v(\" \"),_c('input',{directives:[{name:\"model\",rawName:\"v-model.trim\",value:(_vm.$v.user.fullname.$model),expression:\"$v.user.fullname.$model\",modifiers:{\"trim\":true}}],staticClass:\"form-control\",attrs:{\"id\":\"sign-up-fullname\",\"disabled\":_vm.isPending,\"placeholder\":_vm.$t('registration.fullname_placeholder')},domProps:{\"value\":(_vm.$v.user.fullname.$model)},on:{\"input\":function($event){if($event.target.composing){ return; }_vm.$set(_vm.$v.user.fullname, \"$model\", $event.target.value.trim())},\"blur\":function($event){_vm.$forceUpdate()}}})]),_vm._v(\" \"),(_vm.$v.user.fullname.$dirty)?_c('div',{staticClass:\"form-error\"},[_c('ul',[(!_vm.$v.user.fullname.required)?_c('li',[_c('span',[_vm._v(_vm._s(_vm.$t('registration.validations.fullname_required')))])]):_vm._e()])]):_vm._e(),_vm._v(\" \"),_c('div',{staticClass:\"form-group\",class:{ 'form-group--error': _vm.$v.user.email.$error }},[_c('label',{staticClass:\"form--label\",attrs:{\"for\":\"email\"}},[_vm._v(_vm._s(_vm.$t('registration.email')))]),_vm._v(\" \"),_c('input',{directives:[{name:\"model\",rawName:\"v-model\",value:(_vm.$v.user.email.$model),expression:\"$v.user.email.$model\"}],staticClass:\"form-control\",attrs:{\"id\":\"email\",\"disabled\":_vm.isPending,\"type\":\"email\"},domProps:{\"value\":(_vm.$v.user.email.$model)},on:{\"input\":function($event){if($event.target.composing){ return; }_vm.$set(_vm.$v.user.email, \"$model\", $event.target.value)}}})]),_vm._v(\" \"),(_vm.$v.user.email.$dirty)?_c('div',{staticClass:\"form-error\"},[_c('ul',[(!_vm.$v.user.email.required)?_c('li',[_c('span',[_vm._v(_vm._s(_vm.$t('registration.validations.email_required')))])]):_vm._e()])]):_vm._e(),_vm._v(\" \"),_c('div',{staticClass:\"form-group\"},[_c('label',{staticClass:\"form--label\",attrs:{\"for\":\"bio\"}},[_vm._v(_vm._s(_vm.$t('registration.bio'))+\" (\"+_vm._s(_vm.$t('general.optional'))+\")\")]),_vm._v(\" \"),_c('textarea',{directives:[{name:\"model\",rawName:\"v-model\",value:(_vm.user.bio),expression:\"user.bio\"}],staticClass:\"form-control\",attrs:{\"id\":\"bio\",\"disabled\":_vm.isPending,\"placeholder\":_vm.bioPlaceholder},domProps:{\"value\":(_vm.user.bio)},on:{\"input\":function($event){if($event.target.composing){ return; }_vm.$set(_vm.user, \"bio\", $event.target.value)}}})]),_vm._v(\" \"),_c('div',{staticClass:\"form-group\",class:{ 'form-group--error': _vm.$v.user.password.$error }},[_c('label',{staticClass:\"form--label\",attrs:{\"for\":\"sign-up-password\"}},[_vm._v(_vm._s(_vm.$t('login.password')))]),_vm._v(\" \"),_c('input',{directives:[{name:\"model\",rawName:\"v-model\",value:(_vm.user.password),expression:\"user.password\"}],staticClass:\"form-control\",attrs:{\"id\":\"sign-up-password\",\"disabled\":_vm.isPending,\"type\":\"password\"},domProps:{\"value\":(_vm.user.password)},on:{\"input\":function($event){if($event.target.composing){ return; }_vm.$set(_vm.user, \"password\", $event.target.value)}}})]),_vm._v(\" \"),(_vm.$v.user.password.$dirty)?_c('div',{staticClass:\"form-error\"},[_c('ul',[(!_vm.$v.user.password.required)?_c('li',[_c('span',[_vm._v(_vm._s(_vm.$t('registration.validations.password_required')))])]):_vm._e()])]):_vm._e(),_vm._v(\" \"),_c('div',{staticClass:\"form-group\",class:{ 'form-group--error': _vm.$v.user.confirm.$error }},[_c('label',{staticClass:\"form--label\",attrs:{\"for\":\"sign-up-password-confirmation\"}},[_vm._v(_vm._s(_vm.$t('registration.password_confirm')))]),_vm._v(\" \"),_c('input',{directives:[{name:\"model\",rawName:\"v-model\",value:(_vm.user.confirm),expression:\"user.confirm\"}],staticClass:\"form-control\",attrs:{\"id\":\"sign-up-password-confirmation\",\"disabled\":_vm.isPending,\"type\":\"password\"},domProps:{\"value\":(_vm.user.confirm)},on:{\"input\":function($event){if($event.target.composing){ return; }_vm.$set(_vm.user, \"confirm\", $event.target.value)}}})]),_vm._v(\" \"),(_vm.$v.user.confirm.$dirty)?_c('div',{staticClass:\"form-error\"},[_c('ul',[(!_vm.$v.user.confirm.required)?_c('li',[_c('span',[_vm._v(_vm._s(_vm.$t('registration.validations.password_confirmation_required')))])]):_vm._e(),_vm._v(\" \"),(!_vm.$v.user.confirm.sameAsPassword)?_c('li',[_c('span',[_vm._v(_vm._s(_vm.$t('registration.validations.password_confirmation_match')))])]):_vm._e()])]):_vm._e(),_vm._v(\" \"),(_vm.captcha.type != 'none')?_c('div',{staticClass:\"form-group\",attrs:{\"id\":\"captcha-group\"}},[_c('label',{staticClass:\"form--label\",attrs:{\"for\":\"captcha-label\"}},[_vm._v(_vm._s(_vm.$t('captcha')))]),_vm._v(\" \"),(_vm.captcha.type == 'kocaptcha')?[_c('img',{attrs:{\"src\":_vm.captcha.url},on:{\"click\":_vm.setCaptcha}}),_vm._v(\" \"),_c('sub',[_vm._v(_vm._s(_vm.$t('registration.new_captcha')))]),_vm._v(\" \"),_c('input',{directives:[{name:\"model\",rawName:\"v-model\",value:(_vm.captcha.solution),expression:\"captcha.solution\"}],staticClass:\"form-control\",attrs:{\"id\":\"captcha-answer\",\"disabled\":_vm.isPending,\"type\":\"text\",\"autocomplete\":\"off\"},domProps:{\"value\":(_vm.captcha.solution)},on:{\"input\":function($event){if($event.target.composing){ return; }_vm.$set(_vm.captcha, \"solution\", $event.target.value)}}})]:_vm._e()],2):_vm._e(),_vm._v(\" \"),(_vm.token)?_c('div',{staticClass:\"form-group\"},[_c('label',{attrs:{\"for\":\"token\"}},[_vm._v(_vm._s(_vm.$t('registration.token')))]),_vm._v(\" \"),_c('input',{directives:[{name:\"model\",rawName:\"v-model\",value:(_vm.token),expression:\"token\"}],staticClass:\"form-control\",attrs:{\"id\":\"token\",\"disabled\":\"true\",\"type\":\"text\"},domProps:{\"value\":(_vm.token)},on:{\"input\":function($event){if($event.target.composing){ return; }_vm.token=$event.target.value}}})]):_vm._e(),_vm._v(\" \"),_c('div',{staticClass:\"form-group\"},[_c('button',{staticClass:\"btn btn-default\",attrs:{\"disabled\":_vm.isPending,\"type\":\"submit\"}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('general.submit'))+\"\\n \")])])]),_vm._v(\" \"),_c('div',{staticClass:\"terms-of-service\",domProps:{\"innerHTML\":_vm._s(_vm.termsOfService)}})]),_vm._v(\" \"),(_vm.serverValidationErrors.length)?_c('div',{staticClass:\"form-group\"},[_c('div',{staticClass:\"alert error\"},_vm._l((_vm.serverValidationErrors),function(error){return _c('span',{key:error},[_vm._v(_vm._s(error))])}),0)]):_vm._e()])])])}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:\"settings panel panel-default\"},[_c('div',{staticClass:\"panel-heading\"},[_vm._v(\"\\n \"+_vm._s(_vm.$t('password_reset.password_reset'))+\"\\n \")]),_vm._v(\" \"),_c('div',{staticClass:\"panel-body\"},[_c('form',{staticClass:\"password-reset-form\",on:{\"submit\":function($event){$event.preventDefault();return _vm.submit($event)}}},[_c('div',{staticClass:\"container\"},[(!_vm.mailerEnabled)?_c('div',[(_vm.passwordResetRequested)?_c('p',[_vm._v(\"\\n \"+_vm._s(_vm.$t('password_reset.password_reset_required_but_mailer_is_disabled'))+\"\\n \")]):_c('p',[_vm._v(\"\\n \"+_vm._s(_vm.$t('password_reset.password_reset_disabled'))+\"\\n \")])]):(_vm.success || _vm.throttled)?_c('div',[(_vm.success)?_c('p',[_vm._v(\"\\n \"+_vm._s(_vm.$t('password_reset.check_email'))+\"\\n \")]):_vm._e(),_vm._v(\" \"),_c('div',{staticClass:\"form-group text-center\"},[_c('router-link',{attrs:{\"to\":{name: 'root'}}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('password_reset.return_home'))+\"\\n \")])],1)]):_c('div',[(_vm.passwordResetRequested)?_c('p',{staticClass:\"password-reset-required error\"},[_vm._v(\"\\n \"+_vm._s(_vm.$t('password_reset.password_reset_required'))+\"\\n \")]):_vm._e(),_vm._v(\" \"),_c('p',[_vm._v(\"\\n \"+_vm._s(_vm.$t('password_reset.instruction'))+\"\\n \")]),_vm._v(\" \"),_c('div',{staticClass:\"form-group\"},[_c('input',{directives:[{name:\"model\",rawName:\"v-model\",value:(_vm.user.email),expression:\"user.email\"}],ref:\"email\",staticClass:\"form-control\",attrs:{\"disabled\":_vm.isPending,\"placeholder\":_vm.$t('password_reset.placeholder'),\"type\":\"input\"},domProps:{\"value\":(_vm.user.email)},on:{\"input\":function($event){if($event.target.composing){ return; }_vm.$set(_vm.user, \"email\", $event.target.value)}}})]),_vm._v(\" \"),_c('div',{staticClass:\"form-group\"},[_c('button',{staticClass:\"btn btn-default btn-block\",attrs:{\"disabled\":_vm.isPending,\"type\":\"submit\"}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('general.submit'))+\"\\n \")])])]),_vm._v(\" \"),(_vm.error)?_c('p',{staticClass:\"alert error notice-dismissible\"},[_c('span',[_vm._v(_vm._s(_vm.error))]),_vm._v(\" \"),_c('a',{staticClass:\"button-icon dismiss\",on:{\"click\":function($event){$event.preventDefault();_vm.dismissError()}}},[_c('i',{staticClass:\"icon-cancel\"})])]):_vm._e()])])])])}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:\"image-cropper\"},[(_vm.dataUrl)?_c('div',[_c('div',{staticClass:\"image-cropper-image-container\"},[_c('img',{ref:\"img\",attrs:{\"src\":_vm.dataUrl,\"alt\":\"\"},on:{\"load\":function($event){$event.stopPropagation();return _vm.createCropper($event)}}})]),_vm._v(\" \"),_c('div',{staticClass:\"image-cropper-buttons-wrapper\"},[_c('button',{staticClass:\"btn\",attrs:{\"type\":\"button\",\"disabled\":_vm.submitting},domProps:{\"textContent\":_vm._s(_vm.saveText)},on:{\"click\":function($event){_vm.submit()}}}),_vm._v(\" \"),_c('button',{staticClass:\"btn\",attrs:{\"type\":\"button\",\"disabled\":_vm.submitting},domProps:{\"textContent\":_vm._s(_vm.cancelText)},on:{\"click\":_vm.destroy}}),_vm._v(\" \"),_c('button',{staticClass:\"btn\",attrs:{\"type\":\"button\",\"disabled\":_vm.submitting},domProps:{\"textContent\":_vm._s(_vm.saveWithoutCroppingText)},on:{\"click\":function($event){_vm.submit(false)}}}),_vm._v(\" \"),(_vm.submitting)?_c('i',{staticClass:\"icon-spin4 animate-spin\"}):_vm._e()]),_vm._v(\" \"),(_vm.submitError)?_c('div',{staticClass:\"alert error\"},[_vm._v(\"\\n \"+_vm._s(_vm.submitErrorMsg)+\"\\n \"),_c('i',{staticClass:\"button-icon icon-cancel\",on:{\"click\":_vm.clearError}})]):_vm._e()]):_vm._e(),_vm._v(\" \"),_c('input',{ref:\"input\",staticClass:\"image-cropper-img-input\",attrs:{\"type\":\"file\",\"accept\":_vm.mimes}})])}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('basic-user-card',{attrs:{\"user\":_vm.user}},[_c('div',{staticClass:\"block-card-content-container\"},[(_vm.blocked)?_c('button',{staticClass:\"btn btn-default\",attrs:{\"disabled\":_vm.progress},on:{\"click\":_vm.unblockUser}},[(_vm.progress)?[_vm._v(\"\\n \"+_vm._s(_vm.$t('user_card.unblock_progress'))+\"\\n \")]:[_vm._v(\"\\n \"+_vm._s(_vm.$t('user_card.unblock'))+\"\\n \")]],2):_c('button',{staticClass:\"btn btn-default\",attrs:{\"disabled\":_vm.progress},on:{\"click\":_vm.blockUser}},[(_vm.progress)?[_vm._v(\"\\n \"+_vm._s(_vm.$t('user_card.block_progress'))+\"\\n \")]:[_vm._v(\"\\n \"+_vm._s(_vm.$t('user_card.block'))+\"\\n \")]],2)])])}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('basic-user-card',{attrs:{\"user\":_vm.user}},[_c('div',{staticClass:\"mute-card-content-container\"},[(_vm.muted)?_c('button',{staticClass:\"btn btn-default\",attrs:{\"disabled\":_vm.progress},on:{\"click\":_vm.unmuteUser}},[(_vm.progress)?[_vm._v(\"\\n \"+_vm._s(_vm.$t('user_card.unmute_progress'))+\"\\n \")]:[_vm._v(\"\\n \"+_vm._s(_vm.$t('user_card.unmute'))+\"\\n \")]],2):_c('button',{staticClass:\"btn btn-default\",attrs:{\"disabled\":_vm.progress},on:{\"click\":_vm.muteUser}},[(_vm.progress)?[_vm._v(\"\\n \"+_vm._s(_vm.$t('user_card.mute_progress'))+\"\\n \")]:[_vm._v(\"\\n \"+_vm._s(_vm.$t('user_card.mute'))+\"\\n \")]],2)])])}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:\"selectable-list\"},[(_vm.items.length > 0)?_c('div',{staticClass:\"selectable-list-header\"},[_c('div',{staticClass:\"selectable-list-checkbox-wrapper\"},[_c('Checkbox',{attrs:{\"checked\":_vm.allSelected,\"indeterminate\":_vm.someSelected},on:{\"change\":_vm.toggleAll}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('selectable_list.select_all'))+\"\\n \")])],1),_vm._v(\" \"),_c('div',{staticClass:\"selectable-list-header-actions\"},[_vm._t(\"header\",null,{selected:_vm.filteredSelected})],2)]):_vm._e(),_vm._v(\" \"),_c('List',{attrs:{\"items\":_vm.items,\"get-key\":_vm.getKey},scopedSlots:_vm._u([{key:\"item\",fn:function(ref){\nvar item = ref.item;\nreturn [_c('div',{staticClass:\"selectable-list-item-inner\",class:{ 'selectable-list-item-selected-inner': _vm.isSelected(item) }},[_c('div',{staticClass:\"selectable-list-checkbox-wrapper\"},[_c('Checkbox',{attrs:{\"checked\":_vm.isSelected(item)},on:{\"change\":function (checked) { return _vm.toggle(checked, item); }}})],1),_vm._v(\" \"),_vm._t(\"item\",null,{item:item})],2)]}}])},[_c('template',{slot:\"empty\"},[_vm._t(\"empty\")],2)],2)],1)}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{directives:[{name:\"click-outside\",rawName:\"v-click-outside\",value:(_vm.onClickOutside),expression:\"onClickOutside\"}],staticClass:\"autosuggest\"},[_c('input',{directives:[{name:\"model\",rawName:\"v-model\",value:(_vm.term),expression:\"term\"}],staticClass:\"autosuggest-input\",attrs:{\"placeholder\":_vm.placeholder},domProps:{\"value\":(_vm.term)},on:{\"click\":_vm.onInputClick,\"input\":function($event){if($event.target.composing){ return; }_vm.term=$event.target.value}}}),_vm._v(\" \"),(_vm.resultsVisible && _vm.filtered.length > 0)?_c('div',{staticClass:\"autosuggest-results\"},[_vm._l((_vm.filtered),function(item){return _vm._t(\"default\",null,{item:item})})],2):_vm._e()])}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:\"importer\"},[_c('form',[_c('input',{ref:\"input\",attrs:{\"type\":\"file\"},on:{\"change\":_vm.change}})]),_vm._v(\" \"),(_vm.submitting)?_c('i',{staticClass:\"icon-spin4 animate-spin importer-uploading\"}):_c('button',{staticClass:\"btn btn-default\",on:{\"click\":_vm.submit}},[_vm._v(\"\\n \"+_vm._s(_vm.submitButtonLabel)+\"\\n \")]),_vm._v(\" \"),(_vm.success)?_c('div',[_c('i',{staticClass:\"icon-cross\",on:{\"click\":_vm.dismiss}}),_vm._v(\" \"),_c('p',[_vm._v(_vm._s(_vm.successMessage))])]):(_vm.error)?_c('div',[_c('i',{staticClass:\"icon-cross\",on:{\"click\":_vm.dismiss}}),_vm._v(\" \"),_c('p',[_vm._v(_vm._s(_vm.errorMessage))])]):_vm._e()])}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:\"exporter\"},[(_vm.processing)?_c('div',[_c('i',{staticClass:\"icon-spin4 animate-spin exporter-processing\"}),_vm._v(\" \"),_c('span',[_vm._v(_vm._s(_vm.processingMessage))])]):_c('button',{staticClass:\"btn btn-default\",on:{\"click\":_vm.process}},[_vm._v(\"\\n \"+_vm._s(_vm.exportButtonLabel)+\"\\n \")])])}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',[(_vm.displayTitle)?_c('h4',[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.mfa.recovery_codes'))+\"\\n \")]):_vm._e(),_vm._v(\" \"),(_vm.inProgress)?_c('i',[_vm._v(_vm._s(_vm.$t('settings.mfa.waiting_a_recovery_codes')))]):_vm._e(),_vm._v(\" \"),(_vm.ready)?[_c('p',{staticClass:\"alert warning\"},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.mfa.recovery_codes_warning'))+\"\\n \")]),_vm._v(\" \"),_c('ul',{staticClass:\"backup-codes\"},_vm._l((_vm.backupCodes.codes),function(code){return _c('li',{key:code},[_vm._v(\"\\n \"+_vm._s(code)+\"\\n \")])}),0)]:_vm._e()],2)}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',[_vm._t(\"default\"),_vm._v(\" \"),_c('button',{staticClass:\"btn btn-default\",attrs:{\"disabled\":_vm.disabled},on:{\"click\":_vm.confirm}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('general.confirm'))+\"\\n \")]),_vm._v(\" \"),_c('button',{staticClass:\"btn btn-default\",attrs:{\"disabled\":_vm.disabled},on:{\"click\":_vm.cancel}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('general.cancel'))+\"\\n \")])],2)}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',[_c('div',{staticClass:\"method-item\"},[_c('strong',[_vm._v(_vm._s(_vm.$t('settings.mfa.otp')))]),_vm._v(\" \"),(!_vm.isActivated)?_c('button',{staticClass:\"btn btn-default\",on:{\"click\":_vm.doActivate}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('general.enable'))+\"\\n \")]):_vm._e(),_vm._v(\" \"),(_vm.isActivated)?_c('button',{staticClass:\"btn btn-default\",attrs:{\"disabled\":_vm.deactivate},on:{\"click\":_vm.doDeactivate}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('general.disable'))+\"\\n \")]):_vm._e()]),_vm._v(\" \"),(_vm.deactivate)?_c('confirm',{attrs:{\"disabled\":_vm.inProgress},on:{\"confirm\":_vm.confirmDeactivate,\"cancel\":_vm.cancelDeactivate}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.enter_current_password_to_confirm'))+\":\\n \"),_c('input',{directives:[{name:\"model\",rawName:\"v-model\",value:(_vm.currentPassword),expression:\"currentPassword\"}],attrs:{\"type\":\"password\"},domProps:{\"value\":(_vm.currentPassword)},on:{\"input\":function($event){if($event.target.composing){ return; }_vm.currentPassword=$event.target.value}}})]):_vm._e(),_vm._v(\" \"),(_vm.error)?_c('div',{staticClass:\"alert error\"},[_vm._v(\"\\n \"+_vm._s(_vm.error)+\"\\n \")]):_vm._e()],1)}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return (_vm.readyInit && _vm.settings.available)?_c('div',{staticClass:\"setting-item mfa-settings\"},[_c('div',{staticClass:\"mfa-heading\"},[_c('h2',[_vm._v(_vm._s(_vm.$t('settings.mfa.title')))])]),_vm._v(\" \"),_c('div',[(!_vm.setupInProgress)?_c('div',{staticClass:\"setting-item\"},[_c('h3',[_vm._v(_vm._s(_vm.$t('settings.mfa.authentication_methods')))]),_vm._v(\" \"),_c('totp-item',{attrs:{\"settings\":_vm.settings},on:{\"deactivate\":_vm.fetchSettings,\"activate\":_vm.activateOTP}}),_vm._v(\" \"),_c('br'),_vm._v(\" \"),(_vm.settings.enabled)?_c('div',[(!_vm.confirmNewBackupCodes)?_c('recovery-codes',{attrs:{\"backup-codes\":_vm.backupCodes}}):_vm._e(),_vm._v(\" \"),(!_vm.confirmNewBackupCodes)?_c('button',{staticClass:\"btn btn-default\",on:{\"click\":_vm.getBackupCodes}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.mfa.generate_new_recovery_codes'))+\"\\n \")]):_vm._e(),_vm._v(\" \"),(_vm.confirmNewBackupCodes)?_c('div',[_c('confirm',{attrs:{\"disabled\":_vm.backupCodes.inProgress},on:{\"confirm\":_vm.confirmBackupCodes,\"cancel\":_vm.cancelBackupCodes}},[_c('p',{staticClass:\"warning\"},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.mfa.warning_of_generate_new_codes'))+\"\\n \")])])],1):_vm._e()],1):_vm._e()],1):_vm._e(),_vm._v(\" \"),(_vm.setupInProgress)?_c('div',[_c('h3',[_vm._v(_vm._s(_vm.$t('settings.mfa.setup_otp')))]),_vm._v(\" \"),(!_vm.setupOTPInProgress)?_c('recovery-codes',{attrs:{\"backup-codes\":_vm.backupCodes}}):_vm._e(),_vm._v(\" \"),(_vm.canSetupOTP)?_c('button',{staticClass:\"btn btn-default\",on:{\"click\":_vm.cancelSetup}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('general.cancel'))+\"\\n \")]):_vm._e(),_vm._v(\" \"),(_vm.canSetupOTP)?_c('button',{staticClass:\"btn btn-default\",on:{\"click\":_vm.setupOTP}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.mfa.setup_otp'))+\"\\n \")]):_vm._e(),_vm._v(\" \"),(_vm.setupOTPInProgress)?[(_vm.prepareOTP)?_c('i',[_vm._v(_vm._s(_vm.$t('settings.mfa.wait_pre_setup_otp')))]):_vm._e(),_vm._v(\" \"),(_vm.confirmOTP)?_c('div',[_c('div',{staticClass:\"setup-otp\"},[_c('div',{staticClass:\"qr-code\"},[_c('h4',[_vm._v(_vm._s(_vm.$t('settings.mfa.scan.title')))]),_vm._v(\" \"),_c('p',[_vm._v(_vm._s(_vm.$t('settings.mfa.scan.desc')))]),_vm._v(\" \"),_c('qrcode',{attrs:{\"value\":_vm.otpSettings.provisioning_uri,\"options\":{ width: 200 }}}),_vm._v(\" \"),_c('p',[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.mfa.scan.secret_code'))+\":\\n \"+_vm._s(_vm.otpSettings.key)+\"\\n \")])],1),_vm._v(\" \"),_c('div',{staticClass:\"verify\"},[_c('h4',[_vm._v(_vm._s(_vm.$t('general.verify')))]),_vm._v(\" \"),_c('p',[_vm._v(_vm._s(_vm.$t('settings.mfa.verify.desc')))]),_vm._v(\" \"),_c('input',{directives:[{name:\"model\",rawName:\"v-model\",value:(_vm.otpConfirmToken),expression:\"otpConfirmToken\"}],attrs:{\"type\":\"text\"},domProps:{\"value\":(_vm.otpConfirmToken)},on:{\"input\":function($event){if($event.target.composing){ return; }_vm.otpConfirmToken=$event.target.value}}}),_vm._v(\" \"),_c('p',[_vm._v(_vm._s(_vm.$t('settings.enter_current_password_to_confirm'))+\":\")]),_vm._v(\" \"),_c('input',{directives:[{name:\"model\",rawName:\"v-model\",value:(_vm.currentPassword),expression:\"currentPassword\"}],attrs:{\"type\":\"password\"},domProps:{\"value\":(_vm.currentPassword)},on:{\"input\":function($event){if($event.target.composing){ return; }_vm.currentPassword=$event.target.value}}}),_vm._v(\" \"),_c('div',{staticClass:\"confirm-otp-actions\"},[_c('button',{staticClass:\"btn btn-default\",on:{\"click\":_vm.doConfirmOTP}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.mfa.confirm_and_enable'))+\"\\n \")]),_vm._v(\" \"),_c('button',{staticClass:\"btn btn-default\",on:{\"click\":_vm.cancelSetup}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('general.cancel'))+\"\\n \")])]),_vm._v(\" \"),(_vm.error)?_c('div',{staticClass:\"alert error\"},[_vm._v(\"\\n \"+_vm._s(_vm.error)+\"\\n \")]):_vm._e()])])]):_vm._e()]:_vm._e()],2):_vm._e()])]):_vm._e()}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:\"settings panel panel-default\"},[_c('div',{staticClass:\"panel-heading\"},[_c('div',{staticClass:\"title\"},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.user_settings'))+\"\\n \")]),_vm._v(\" \"),_c('transition',{attrs:{\"name\":\"fade\"}},[(_vm.currentSaveStateNotice)?[(_vm.currentSaveStateNotice.error)?_c('div',{staticClass:\"alert error\",on:{\"click\":function($event){$event.preventDefault();}}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.saving_err'))+\"\\n \")]):_vm._e(),_vm._v(\" \"),(!_vm.currentSaveStateNotice.error)?_c('div',{staticClass:\"alert transparent\",on:{\"click\":function($event){$event.preventDefault();}}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.saving_ok'))+\"\\n \")]):_vm._e()]:_vm._e()],2)],1),_vm._v(\" \"),_c('div',{staticClass:\"panel-body profile-edit\"},[_c('tab-switcher',[_c('div',{attrs:{\"label\":_vm.$t('settings.profile_tab')}},[_c('div',{staticClass:\"setting-item\"},[_c('h2',[_vm._v(_vm._s(_vm.$t('settings.name_bio')))]),_vm._v(\" \"),_c('p',[_vm._v(_vm._s(_vm.$t('settings.name')))]),_vm._v(\" \"),_c('EmojiInput',{attrs:{\"enable-emoji-picker\":\"\",\"suggest\":_vm.emojiSuggestor},model:{value:(_vm.newName),callback:function ($$v) {_vm.newName=$$v},expression:\"newName\"}},[_c('input',{directives:[{name:\"model\",rawName:\"v-model\",value:(_vm.newName),expression:\"newName\"}],attrs:{\"id\":\"username\",\"classname\":\"name-changer\"},domProps:{\"value\":(_vm.newName)},on:{\"input\":function($event){if($event.target.composing){ return; }_vm.newName=$event.target.value}}})]),_vm._v(\" \"),_c('p',[_vm._v(_vm._s(_vm.$t('settings.bio')))]),_vm._v(\" \"),_c('EmojiInput',{attrs:{\"enable-emoji-picker\":\"\",\"suggest\":_vm.emojiUserSuggestor},model:{value:(_vm.newBio),callback:function ($$v) {_vm.newBio=$$v},expression:\"newBio\"}},[_c('textarea',{directives:[{name:\"model\",rawName:\"v-model\",value:(_vm.newBio),expression:\"newBio\"}],attrs:{\"classname\":\"bio\"},domProps:{\"value\":(_vm.newBio)},on:{\"input\":function($event){if($event.target.composing){ return; }_vm.newBio=$event.target.value}}})]),_vm._v(\" \"),_c('p',[_c('Checkbox',{model:{value:(_vm.newLocked),callback:function ($$v) {_vm.newLocked=$$v},expression:\"newLocked\"}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.lock_account_description'))+\"\\n \")])],1),_vm._v(\" \"),_c('div',[_c('label',{attrs:{\"for\":\"default-vis\"}},[_vm._v(_vm._s(_vm.$t('settings.default_vis')))]),_vm._v(\" \"),_c('div',{staticClass:\"visibility-tray\",attrs:{\"id\":\"default-vis\"}},[_c('scope-selector',{attrs:{\"show-all\":true,\"user-default\":_vm.newDefaultScope,\"initial-scope\":_vm.newDefaultScope,\"on-scope-change\":_vm.changeVis}})],1)]),_vm._v(\" \"),_c('p',[_c('Checkbox',{model:{value:(_vm.newNoRichText),callback:function ($$v) {_vm.newNoRichText=$$v},expression:\"newNoRichText\"}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.no_rich_text_description'))+\"\\n \")])],1),_vm._v(\" \"),_c('p',[_c('Checkbox',{model:{value:(_vm.hideFollows),callback:function ($$v) {_vm.hideFollows=$$v},expression:\"hideFollows\"}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.hide_follows_description'))+\"\\n \")])],1),_vm._v(\" \"),_c('p',{staticClass:\"setting-subitem\"},[_c('Checkbox',{attrs:{\"disabled\":!_vm.hideFollows},model:{value:(_vm.hideFollowsCount),callback:function ($$v) {_vm.hideFollowsCount=$$v},expression:\"hideFollowsCount\"}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.hide_follows_count_description'))+\"\\n \")])],1),_vm._v(\" \"),_c('p',[_c('Checkbox',{model:{value:(_vm.hideFollowers),callback:function ($$v) {_vm.hideFollowers=$$v},expression:\"hideFollowers\"}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.hide_followers_description'))+\"\\n \")])],1),_vm._v(\" \"),_c('p',{staticClass:\"setting-subitem\"},[_c('Checkbox',{attrs:{\"disabled\":!_vm.hideFollowers},model:{value:(_vm.hideFollowersCount),callback:function ($$v) {_vm.hideFollowersCount=$$v},expression:\"hideFollowersCount\"}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.hide_followers_count_description'))+\"\\n \")])],1),_vm._v(\" \"),_c('p',[_c('Checkbox',{model:{value:(_vm.showRole),callback:function ($$v) {_vm.showRole=$$v},expression:\"showRole\"}},[(_vm.role === 'admin')?[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.show_admin_badge'))+\"\\n \")]:_vm._e(),_vm._v(\" \"),(_vm.role === 'moderator')?[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.show_moderator_badge'))+\"\\n \")]:_vm._e()],2)],1),_vm._v(\" \"),_c('p',[_c('Checkbox',{model:{value:(_vm.discoverable),callback:function ($$v) {_vm.discoverable=$$v},expression:\"discoverable\"}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.discoverable'))+\"\\n \")])],1),_vm._v(\" \"),_c('button',{staticClass:\"btn btn-default\",attrs:{\"disabled\":_vm.newName && _vm.newName.length === 0},on:{\"click\":_vm.updateProfile}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('general.submit'))+\"\\n \")])],1),_vm._v(\" \"),_c('div',{staticClass:\"setting-item\"},[_c('h2',[_vm._v(_vm._s(_vm.$t('settings.avatar')))]),_vm._v(\" \"),_c('p',{staticClass:\"visibility-notice\"},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.avatar_size_instruction'))+\"\\n \")]),_vm._v(\" \"),_c('p',[_vm._v(_vm._s(_vm.$t('settings.current_avatar')))]),_vm._v(\" \"),_c('img',{staticClass:\"current-avatar\",attrs:{\"src\":_vm.user.profile_image_url_original}}),_vm._v(\" \"),_c('p',[_vm._v(_vm._s(_vm.$t('settings.set_new_avatar')))]),_vm._v(\" \"),_c('button',{directives:[{name:\"show\",rawName:\"v-show\",value:(_vm.pickAvatarBtnVisible),expression:\"pickAvatarBtnVisible\"}],staticClass:\"btn\",attrs:{\"id\":\"pick-avatar\",\"type\":\"button\"}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.upload_a_photo'))+\"\\n \")]),_vm._v(\" \"),_c('image-cropper',{attrs:{\"trigger\":\"#pick-avatar\",\"submit-handler\":_vm.submitAvatar},on:{\"open\":function($event){_vm.pickAvatarBtnVisible=false},\"close\":function($event){_vm.pickAvatarBtnVisible=true}}})],1),_vm._v(\" \"),_c('div',{staticClass:\"setting-item\"},[_c('h2',[_vm._v(_vm._s(_vm.$t('settings.profile_banner')))]),_vm._v(\" \"),_c('p',[_vm._v(_vm._s(_vm.$t('settings.current_profile_banner')))]),_vm._v(\" \"),_c('img',{staticClass:\"banner\",attrs:{\"src\":_vm.user.cover_photo}}),_vm._v(\" \"),_c('p',[_vm._v(_vm._s(_vm.$t('settings.set_new_profile_banner')))]),_vm._v(\" \"),(_vm.bannerPreview)?_c('img',{staticClass:\"banner\",attrs:{\"src\":_vm.bannerPreview}}):_vm._e(),_vm._v(\" \"),_c('div',[_c('input',{attrs:{\"type\":\"file\"},on:{\"change\":function($event){_vm.uploadFile('banner', $event)}}})]),_vm._v(\" \"),(_vm.bannerUploading)?_c('i',{staticClass:\" icon-spin4 animate-spin uploading\"}):(_vm.bannerPreview)?_c('button',{staticClass:\"btn btn-default\",on:{\"click\":_vm.submitBanner}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('general.submit'))+\"\\n \")]):_vm._e(),_vm._v(\" \"),(_vm.bannerUploadError)?_c('div',{staticClass:\"alert error\"},[_vm._v(\"\\n Error: \"+_vm._s(_vm.bannerUploadError)+\"\\n \"),_c('i',{staticClass:\"button-icon icon-cancel\",on:{\"click\":function($event){_vm.clearUploadError('banner')}}})]):_vm._e()]),_vm._v(\" \"),_c('div',{staticClass:\"setting-item\"},[_c('h2',[_vm._v(_vm._s(_vm.$t('settings.profile_background')))]),_vm._v(\" \"),_c('p',[_vm._v(_vm._s(_vm.$t('settings.set_new_profile_background')))]),_vm._v(\" \"),(_vm.backgroundPreview)?_c('img',{staticClass:\"bg\",attrs:{\"src\":_vm.backgroundPreview}}):_vm._e(),_vm._v(\" \"),_c('div',[_c('input',{attrs:{\"type\":\"file\"},on:{\"change\":function($event){_vm.uploadFile('background', $event)}}})]),_vm._v(\" \"),(_vm.backgroundUploading)?_c('i',{staticClass:\" icon-spin4 animate-spin uploading\"}):(_vm.backgroundPreview)?_c('button',{staticClass:\"btn btn-default\",on:{\"click\":_vm.submitBg}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('general.submit'))+\"\\n \")]):_vm._e(),_vm._v(\" \"),(_vm.backgroundUploadError)?_c('div',{staticClass:\"alert error\"},[_vm._v(\"\\n Error: \"+_vm._s(_vm.backgroundUploadError)+\"\\n \"),_c('i',{staticClass:\"button-icon icon-cancel\",on:{\"click\":function($event){_vm.clearUploadError('background')}}})]):_vm._e()])]),_vm._v(\" \"),_c('div',{attrs:{\"label\":_vm.$t('settings.security_tab')}},[_c('div',{staticClass:\"setting-item\"},[_c('h2',[_vm._v(_vm._s(_vm.$t('settings.change_email')))]),_vm._v(\" \"),_c('div',[_c('p',[_vm._v(_vm._s(_vm.$t('settings.new_email')))]),_vm._v(\" \"),_c('input',{directives:[{name:\"model\",rawName:\"v-model\",value:(_vm.newEmail),expression:\"newEmail\"}],attrs:{\"type\":\"email\",\"autocomplete\":\"email\"},domProps:{\"value\":(_vm.newEmail)},on:{\"input\":function($event){if($event.target.composing){ return; }_vm.newEmail=$event.target.value}}})]),_vm._v(\" \"),_c('div',[_c('p',[_vm._v(_vm._s(_vm.$t('settings.current_password')))]),_vm._v(\" \"),_c('input',{directives:[{name:\"model\",rawName:\"v-model\",value:(_vm.changeEmailPassword),expression:\"changeEmailPassword\"}],attrs:{\"type\":\"password\",\"autocomplete\":\"current-password\"},domProps:{\"value\":(_vm.changeEmailPassword)},on:{\"input\":function($event){if($event.target.composing){ return; }_vm.changeEmailPassword=$event.target.value}}})]),_vm._v(\" \"),_c('button',{staticClass:\"btn btn-default\",on:{\"click\":_vm.changeEmail}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('general.submit'))+\"\\n \")]),_vm._v(\" \"),(_vm.changedEmail)?_c('p',[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.changed_email'))+\"\\n \")]):_vm._e(),_vm._v(\" \"),(_vm.changeEmailError !== false)?[_c('p',[_vm._v(_vm._s(_vm.$t('settings.change_email_error')))]),_vm._v(\" \"),_c('p',[_vm._v(_vm._s(_vm.changeEmailError))])]:_vm._e()],2),_vm._v(\" \"),_c('div',{staticClass:\"setting-item\"},[_c('h2',[_vm._v(_vm._s(_vm.$t('settings.change_password')))]),_vm._v(\" \"),_c('div',[_c('p',[_vm._v(_vm._s(_vm.$t('settings.current_password')))]),_vm._v(\" \"),_c('input',{directives:[{name:\"model\",rawName:\"v-model\",value:(_vm.changePasswordInputs[0]),expression:\"changePasswordInputs[0]\"}],attrs:{\"type\":\"password\"},domProps:{\"value\":(_vm.changePasswordInputs[0])},on:{\"input\":function($event){if($event.target.composing){ return; }_vm.$set(_vm.changePasswordInputs, 0, $event.target.value)}}})]),_vm._v(\" \"),_c('div',[_c('p',[_vm._v(_vm._s(_vm.$t('settings.new_password')))]),_vm._v(\" \"),_c('input',{directives:[{name:\"model\",rawName:\"v-model\",value:(_vm.changePasswordInputs[1]),expression:\"changePasswordInputs[1]\"}],attrs:{\"type\":\"password\"},domProps:{\"value\":(_vm.changePasswordInputs[1])},on:{\"input\":function($event){if($event.target.composing){ return; }_vm.$set(_vm.changePasswordInputs, 1, $event.target.value)}}})]),_vm._v(\" \"),_c('div',[_c('p',[_vm._v(_vm._s(_vm.$t('settings.confirm_new_password')))]),_vm._v(\" \"),_c('input',{directives:[{name:\"model\",rawName:\"v-model\",value:(_vm.changePasswordInputs[2]),expression:\"changePasswordInputs[2]\"}],attrs:{\"type\":\"password\"},domProps:{\"value\":(_vm.changePasswordInputs[2])},on:{\"input\":function($event){if($event.target.composing){ return; }_vm.$set(_vm.changePasswordInputs, 2, $event.target.value)}}})]),_vm._v(\" \"),_c('button',{staticClass:\"btn btn-default\",on:{\"click\":_vm.changePassword}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('general.submit'))+\"\\n \")]),_vm._v(\" \"),(_vm.changedPassword)?_c('p',[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.changed_password'))+\"\\n \")]):(_vm.changePasswordError !== false)?_c('p',[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.change_password_error'))+\"\\n \")]):_vm._e(),_vm._v(\" \"),(_vm.changePasswordError)?_c('p',[_vm._v(\"\\n \"+_vm._s(_vm.changePasswordError)+\"\\n \")]):_vm._e()]),_vm._v(\" \"),_c('div',{staticClass:\"setting-item\"},[_c('h2',[_vm._v(_vm._s(_vm.$t('settings.oauth_tokens')))]),_vm._v(\" \"),_c('table',{staticClass:\"oauth-tokens\"},[_c('thead',[_c('tr',[_c('th',[_vm._v(_vm._s(_vm.$t('settings.app_name')))]),_vm._v(\" \"),_c('th',[_vm._v(_vm._s(_vm.$t('settings.valid_until')))]),_vm._v(\" \"),_c('th')])]),_vm._v(\" \"),_c('tbody',_vm._l((_vm.oauthTokens),function(oauthToken){return _c('tr',{key:oauthToken.id},[_c('td',[_vm._v(_vm._s(oauthToken.appName))]),_vm._v(\" \"),_c('td',[_vm._v(_vm._s(oauthToken.validUntil))]),_vm._v(\" \"),_c('td',{staticClass:\"actions\"},[_c('button',{staticClass:\"btn btn-default\",on:{\"click\":function($event){_vm.revokeToken(oauthToken.id)}}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.revoke_token'))+\"\\n \")])])])}),0)])]),_vm._v(\" \"),_c('mfa'),_vm._v(\" \"),_c('div',{staticClass:\"setting-item\"},[_c('h2',[_vm._v(_vm._s(_vm.$t('settings.delete_account')))]),_vm._v(\" \"),(!_vm.deletingAccount)?_c('p',[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.delete_account_description'))+\"\\n \")]):_vm._e(),_vm._v(\" \"),(_vm.deletingAccount)?_c('div',[_c('p',[_vm._v(_vm._s(_vm.$t('settings.delete_account_instructions')))]),_vm._v(\" \"),_c('p',[_vm._v(_vm._s(_vm.$t('login.password')))]),_vm._v(\" \"),_c('input',{directives:[{name:\"model\",rawName:\"v-model\",value:(_vm.deleteAccountConfirmPasswordInput),expression:\"deleteAccountConfirmPasswordInput\"}],attrs:{\"type\":\"password\"},domProps:{\"value\":(_vm.deleteAccountConfirmPasswordInput)},on:{\"input\":function($event){if($event.target.composing){ return; }_vm.deleteAccountConfirmPasswordInput=$event.target.value}}}),_vm._v(\" \"),_c('button',{staticClass:\"btn btn-default\",on:{\"click\":_vm.deleteAccount}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.delete_account'))+\"\\n \")])]):_vm._e(),_vm._v(\" \"),(_vm.deleteAccountError !== false)?_c('p',[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.delete_account_error'))+\"\\n \")]):_vm._e(),_vm._v(\" \"),(_vm.deleteAccountError)?_c('p',[_vm._v(\"\\n \"+_vm._s(_vm.deleteAccountError)+\"\\n \")]):_vm._e(),_vm._v(\" \"),(!_vm.deletingAccount)?_c('button',{staticClass:\"btn btn-default\",on:{\"click\":_vm.confirmDelete}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('general.submit'))+\"\\n \")]):_vm._e()])],1),_vm._v(\" \"),(_vm.pleromaBackend)?_c('div',{attrs:{\"label\":_vm.$t('settings.notifications')}},[_c('div',{staticClass:\"setting-item\"},[_c('div',{staticClass:\"select-multiple\"},[_c('span',{staticClass:\"label\"},[_vm._v(_vm._s(_vm.$t('settings.notification_setting')))]),_vm._v(\" \"),_c('ul',{staticClass:\"option-list\"},[_c('li',[_c('Checkbox',{model:{value:(_vm.notificationSettings.follows),callback:function ($$v) {_vm.$set(_vm.notificationSettings, \"follows\", $$v)},expression:\"notificationSettings.follows\"}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.notification_setting_follows'))+\"\\n \")])],1),_vm._v(\" \"),_c('li',[_c('Checkbox',{model:{value:(_vm.notificationSettings.followers),callback:function ($$v) {_vm.$set(_vm.notificationSettings, \"followers\", $$v)},expression:\"notificationSettings.followers\"}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.notification_setting_followers'))+\"\\n \")])],1),_vm._v(\" \"),_c('li',[_c('Checkbox',{model:{value:(_vm.notificationSettings.non_follows),callback:function ($$v) {_vm.$set(_vm.notificationSettings, \"non_follows\", $$v)},expression:\"notificationSettings.non_follows\"}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.notification_setting_non_follows'))+\"\\n \")])],1),_vm._v(\" \"),_c('li',[_c('Checkbox',{model:{value:(_vm.notificationSettings.non_followers),callback:function ($$v) {_vm.$set(_vm.notificationSettings, \"non_followers\", $$v)},expression:\"notificationSettings.non_followers\"}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.notification_setting_non_followers'))+\"\\n \")])],1)])]),_vm._v(\" \"),_c('p',[_vm._v(_vm._s(_vm.$t('settings.notification_mutes')))]),_vm._v(\" \"),_c('p',[_vm._v(_vm._s(_vm.$t('settings.notification_blocks')))]),_vm._v(\" \"),_c('button',{staticClass:\"btn btn-default\",on:{\"click\":_vm.updateNotificationSettings}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('general.submit'))+\"\\n \")])])]):_vm._e(),_vm._v(\" \"),(_vm.pleromaBackend)?_c('div',{attrs:{\"label\":_vm.$t('settings.data_import_export_tab')}},[_c('div',{staticClass:\"setting-item\"},[_c('h2',[_vm._v(_vm._s(_vm.$t('settings.follow_import')))]),_vm._v(\" \"),_c('p',[_vm._v(_vm._s(_vm.$t('settings.import_followers_from_a_csv_file')))]),_vm._v(\" \"),_c('Importer',{attrs:{\"submit-handler\":_vm.importFollows,\"success-message\":_vm.$t('settings.follows_imported'),\"error-message\":_vm.$t('settings.follow_import_error')}})],1),_vm._v(\" \"),_c('div',{staticClass:\"setting-item\"},[_c('h2',[_vm._v(_vm._s(_vm.$t('settings.follow_export')))]),_vm._v(\" \"),_c('Exporter',{attrs:{\"get-content\":_vm.getFollowsContent,\"filename\":\"friends.csv\",\"export-button-label\":_vm.$t('settings.follow_export_button')}})],1),_vm._v(\" \"),_c('div',{staticClass:\"setting-item\"},[_c('h2',[_vm._v(_vm._s(_vm.$t('settings.block_import')))]),_vm._v(\" \"),_c('p',[_vm._v(_vm._s(_vm.$t('settings.import_blocks_from_a_csv_file')))]),_vm._v(\" \"),_c('Importer',{attrs:{\"submit-handler\":_vm.importBlocks,\"success-message\":_vm.$t('settings.blocks_imported'),\"error-message\":_vm.$t('settings.block_import_error')}})],1),_vm._v(\" \"),_c('div',{staticClass:\"setting-item\"},[_c('h2',[_vm._v(_vm._s(_vm.$t('settings.block_export')))]),_vm._v(\" \"),_c('Exporter',{attrs:{\"get-content\":_vm.getBlocksContent,\"filename\":\"blocks.csv\",\"export-button-label\":_vm.$t('settings.block_export_button')}})],1)]):_vm._e(),_vm._v(\" \"),_c('div',{attrs:{\"label\":_vm.$t('settings.blocks_tab')}},[_c('div',{staticClass:\"profile-edit-usersearch-wrapper\"},[_c('Autosuggest',{attrs:{\"filter\":_vm.filterUnblockedUsers,\"query\":_vm.queryUserIds,\"placeholder\":_vm.$t('settings.search_user_to_block')},scopedSlots:_vm._u([{key:\"default\",fn:function(row){return _c('BlockCard',{attrs:{\"user-id\":row.item}})}}])})],1),_vm._v(\" \"),_c('BlockList',{attrs:{\"refresh\":true,\"get-key\":_vm.identity},scopedSlots:_vm._u([{key:\"header\",fn:function(ref){\nvar selected = ref.selected;\nreturn [_c('div',{staticClass:\"profile-edit-bulk-actions\"},[(selected.length > 0)?_c('ProgressButton',{staticClass:\"btn btn-default\",attrs:{\"click\":function () { return _vm.blockUsers(selected); }}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('user_card.block'))+\"\\n \"),_c('template',{slot:\"progress\"},[_vm._v(\"\\n \"+_vm._s(_vm.$t('user_card.block_progress'))+\"\\n \")])],2):_vm._e(),_vm._v(\" \"),(selected.length > 0)?_c('ProgressButton',{staticClass:\"btn btn-default\",attrs:{\"click\":function () { return _vm.unblockUsers(selected); }}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('user_card.unblock'))+\"\\n \"),_c('template',{slot:\"progress\"},[_vm._v(\"\\n \"+_vm._s(_vm.$t('user_card.unblock_progress'))+\"\\n \")])],2):_vm._e()],1)]}},{key:\"item\",fn:function(ref){\nvar item = ref.item;\nreturn [_c('BlockCard',{attrs:{\"user-id\":item}})]}}])},[_c('template',{slot:\"empty\"},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.no_blocks'))+\"\\n \")])],2)],1),_vm._v(\" \"),_c('div',{attrs:{\"label\":_vm.$t('settings.mutes_tab')}},[_c('div',{staticClass:\"profile-edit-usersearch-wrapper\"},[_c('Autosuggest',{attrs:{\"filter\":_vm.filterUnMutedUsers,\"query\":_vm.queryUserIds,\"placeholder\":_vm.$t('settings.search_user_to_mute')},scopedSlots:_vm._u([{key:\"default\",fn:function(row){return _c('MuteCard',{attrs:{\"user-id\":row.item}})}}])})],1),_vm._v(\" \"),_c('MuteList',{attrs:{\"refresh\":true,\"get-key\":_vm.identity},scopedSlots:_vm._u([{key:\"header\",fn:function(ref){\nvar selected = ref.selected;\nreturn [_c('div',{staticClass:\"profile-edit-bulk-actions\"},[(selected.length > 0)?_c('ProgressButton',{staticClass:\"btn btn-default\",attrs:{\"click\":function () { return _vm.muteUsers(selected); }}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('user_card.mute'))+\"\\n \"),_c('template',{slot:\"progress\"},[_vm._v(\"\\n \"+_vm._s(_vm.$t('user_card.mute_progress'))+\"\\n \")])],2):_vm._e(),_vm._v(\" \"),(selected.length > 0)?_c('ProgressButton',{staticClass:\"btn btn-default\",attrs:{\"click\":function () { return _vm.unmuteUsers(selected); }}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('user_card.unmute'))+\"\\n \"),_c('template',{slot:\"progress\"},[_vm._v(\"\\n \"+_vm._s(_vm.$t('user_card.unmute_progress'))+\"\\n \")])],2):_vm._e()],1)]}},{key:\"item\",fn:function(ref){\nvar item = ref.item;\nreturn [_c('MuteCard',{attrs:{\"user-id\":item}})]}}])},[_c('template',{slot:\"empty\"},[_vm._v(\"\\n \"+_vm._s(_vm.$t('settings.no_mutes'))+\"\\n \")])],2)],1)])],1)])}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('basic-user-card',{attrs:{\"user\":_vm.user}},[_c('div',{staticClass:\"follow-request-card-content-container\"},[_c('button',{staticClass:\"btn btn-default\",on:{\"click\":_vm.approveUser}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('user_card.approve'))+\"\\n \")]),_vm._v(\" \"),_c('button',{staticClass:\"btn btn-default\",on:{\"click\":_vm.denyUser}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('user_card.deny'))+\"\\n \")])])])}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:\"settings panel panel-default\"},[_c('div',{staticClass:\"panel-heading\"},[_vm._v(\"\\n \"+_vm._s(_vm.$t('nav.friend_requests'))+\"\\n \")]),_vm._v(\" \"),_c('div',{staticClass:\"panel-body\"},_vm._l((_vm.requests),function(request){return _c('FollowRequestCard',{key:request.id,staticClass:\"list-item\",attrs:{\"user\":request}})}),1)])}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('h1',[_vm._v(\"...\")])}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:\"login panel panel-default\"},[_c('div',{staticClass:\"panel-heading\"},[_vm._v(\"\\n \"+_vm._s(_vm.$t('login.login'))+\"\\n \")]),_vm._v(\" \"),_c('div',{staticClass:\"panel-body\"},[_c('form',{staticClass:\"login-form\",on:{\"submit\":function($event){$event.preventDefault();return _vm.submit($event)}}},[(_vm.isPasswordAuth)?[_c('div',{staticClass:\"form-group\"},[_c('label',{attrs:{\"for\":\"username\"}},[_vm._v(_vm._s(_vm.$t('login.username')))]),_vm._v(\" \"),_c('input',{directives:[{name:\"model\",rawName:\"v-model\",value:(_vm.user.username),expression:\"user.username\"}],staticClass:\"form-control\",attrs:{\"id\":\"username\",\"disabled\":_vm.loggingIn,\"placeholder\":_vm.$t('login.placeholder')},domProps:{\"value\":(_vm.user.username)},on:{\"input\":function($event){if($event.target.composing){ return; }_vm.$set(_vm.user, \"username\", $event.target.value)}}})]),_vm._v(\" \"),_c('div',{staticClass:\"form-group\"},[_c('label',{attrs:{\"for\":\"password\"}},[_vm._v(_vm._s(_vm.$t('login.password')))]),_vm._v(\" \"),_c('input',{directives:[{name:\"model\",rawName:\"v-model\",value:(_vm.user.password),expression:\"user.password\"}],ref:\"passwordInput\",staticClass:\"form-control\",attrs:{\"id\":\"password\",\"disabled\":_vm.loggingIn,\"type\":\"password\"},domProps:{\"value\":(_vm.user.password)},on:{\"input\":function($event){if($event.target.composing){ return; }_vm.$set(_vm.user, \"password\", $event.target.value)}}})]),_vm._v(\" \"),_c('div',{staticClass:\"form-group\"},[_c('router-link',{attrs:{\"to\":{name: 'password-reset'}}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('password_reset.forgot_password'))+\"\\n \")])],1)]:_vm._e(),_vm._v(\" \"),(_vm.isTokenAuth)?_c('div',{staticClass:\"form-group\"},[_c('p',[_vm._v(_vm._s(_vm.$t('login.description')))])]):_vm._e(),_vm._v(\" \"),_c('div',{staticClass:\"form-group\"},[_c('div',{staticClass:\"login-bottom\"},[_c('div',[(_vm.registrationOpen)?_c('router-link',{staticClass:\"register\",attrs:{\"to\":{name: 'registration'}}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('login.register'))+\"\\n \")]):_vm._e()],1),_vm._v(\" \"),_c('button',{staticClass:\"btn btn-default\",attrs:{\"disabled\":_vm.loggingIn,\"type\":\"submit\"}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('login.login'))+\"\\n \")])])])],2)]),_vm._v(\" \"),(_vm.error)?_c('div',{staticClass:\"form-group\"},[_c('div',{staticClass:\"alert error\"},[_vm._v(\"\\n \"+_vm._s(_vm.error)+\"\\n \"),_c('i',{staticClass:\"button-icon icon-cancel\",on:{\"click\":_vm.clearError}})])]):_vm._e()])}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:\"login panel panel-default\"},[_c('div',{staticClass:\"panel-heading\"},[_vm._v(\"\\n \"+_vm._s(_vm.$t('login.heading.recovery'))+\"\\n \")]),_vm._v(\" \"),_c('div',{staticClass:\"panel-body\"},[_c('form',{staticClass:\"login-form\",on:{\"submit\":function($event){$event.preventDefault();return _vm.submit($event)}}},[_c('div',{staticClass:\"form-group\"},[_c('label',{attrs:{\"for\":\"code\"}},[_vm._v(_vm._s(_vm.$t('login.recovery_code')))]),_vm._v(\" \"),_c('input',{directives:[{name:\"model\",rawName:\"v-model\",value:(_vm.code),expression:\"code\"}],staticClass:\"form-control\",attrs:{\"id\":\"code\"},domProps:{\"value\":(_vm.code)},on:{\"input\":function($event){if($event.target.composing){ return; }_vm.code=$event.target.value}}})]),_vm._v(\" \"),_c('div',{staticClass:\"form-group\"},[_c('div',{staticClass:\"login-bottom\"},[_c('div',[_c('a',{attrs:{\"href\":\"#\"},on:{\"click\":function($event){$event.preventDefault();return _vm.requireTOTP($event)}}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('login.enter_two_factor_code'))+\"\\n \")]),_vm._v(\" \"),_c('br'),_vm._v(\" \"),_c('a',{attrs:{\"href\":\"#\"},on:{\"click\":function($event){$event.preventDefault();return _vm.abortMFA($event)}}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('general.cancel'))+\"\\n \")])]),_vm._v(\" \"),_c('button',{staticClass:\"btn btn-default\",attrs:{\"type\":\"submit\"}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('general.verify'))+\"\\n \")])])])])]),_vm._v(\" \"),(_vm.error)?_c('div',{staticClass:\"form-group\"},[_c('div',{staticClass:\"alert error\"},[_vm._v(\"\\n \"+_vm._s(_vm.error)+\"\\n \"),_c('i',{staticClass:\"button-icon icon-cancel\",on:{\"click\":_vm.clearError}})])]):_vm._e()])}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:\"login panel panel-default\"},[_c('div',{staticClass:\"panel-heading\"},[_vm._v(\"\\n \"+_vm._s(_vm.$t('login.heading.totp'))+\"\\n \")]),_vm._v(\" \"),_c('div',{staticClass:\"panel-body\"},[_c('form',{staticClass:\"login-form\",on:{\"submit\":function($event){$event.preventDefault();return _vm.submit($event)}}},[_c('div',{staticClass:\"form-group\"},[_c('label',{attrs:{\"for\":\"code\"}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('login.authentication_code'))+\"\\n \")]),_vm._v(\" \"),_c('input',{directives:[{name:\"model\",rawName:\"v-model\",value:(_vm.code),expression:\"code\"}],staticClass:\"form-control\",attrs:{\"id\":\"code\"},domProps:{\"value\":(_vm.code)},on:{\"input\":function($event){if($event.target.composing){ return; }_vm.code=$event.target.value}}})]),_vm._v(\" \"),_c('div',{staticClass:\"form-group\"},[_c('div',{staticClass:\"login-bottom\"},[_c('div',[_c('a',{attrs:{\"href\":\"#\"},on:{\"click\":function($event){$event.preventDefault();return _vm.requireRecovery($event)}}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('login.enter_recovery_code'))+\"\\n \")]),_vm._v(\" \"),_c('br'),_vm._v(\" \"),_c('a',{attrs:{\"href\":\"#\"},on:{\"click\":function($event){$event.preventDefault();return _vm.abortMFA($event)}}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('general.cancel'))+\"\\n \")])]),_vm._v(\" \"),_c('button',{staticClass:\"btn btn-default\",attrs:{\"type\":\"submit\"}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('general.verify'))+\"\\n \")])])])])]),_vm._v(\" \"),(_vm.error)?_c('div',{staticClass:\"form-group\"},[_c('div',{staticClass:\"alert error\"},[_vm._v(\"\\n \"+_vm._s(_vm.error)+\"\\n \"),_c('i',{staticClass:\"button-icon icon-cancel\",on:{\"click\":_vm.clearError}})])]):_vm._e()])}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return (!_vm.collapsed || !_vm.floating)?_c('div',{staticClass:\"chat-panel\"},[_c('div',{staticClass:\"panel panel-default\"},[_c('div',{staticClass:\"panel-heading timeline-heading\",class:{ 'chat-heading': _vm.floating },on:{\"click\":function($event){$event.stopPropagation();$event.preventDefault();return _vm.togglePanel($event)}}},[_c('div',{staticClass:\"title\"},[_c('span',[_vm._v(_vm._s(_vm.$t('chat.title')))]),_vm._v(\" \"),(_vm.floating)?_c('i',{staticClass:\"icon-cancel\"}):_vm._e()])]),_vm._v(\" \"),_c('div',{directives:[{name:\"chat-scroll\",rawName:\"v-chat-scroll\"}],staticClass:\"chat-window\"},_vm._l((_vm.messages),function(message){return _c('div',{key:message.id,staticClass:\"chat-message\"},[_c('span',{staticClass:\"chat-avatar\"},[_c('img',{attrs:{\"src\":message.author.avatar}})]),_vm._v(\" \"),_c('div',{staticClass:\"chat-content\"},[_c('router-link',{staticClass:\"chat-name\",attrs:{\"to\":_vm.userProfileLink(message.author)}},[_vm._v(\"\\n \"+_vm._s(message.author.username)+\"\\n \")]),_vm._v(\" \"),_c('br'),_vm._v(\" \"),_c('span',{staticClass:\"chat-text\"},[_vm._v(\"\\n \"+_vm._s(message.text)+\"\\n \")])],1)])}),0),_vm._v(\" \"),_c('div',{staticClass:\"chat-input\"},[_c('textarea',{directives:[{name:\"model\",rawName:\"v-model\",value:(_vm.currentMessage),expression:\"currentMessage\"}],staticClass:\"chat-input-textarea\",attrs:{\"rows\":\"1\"},domProps:{\"value\":(_vm.currentMessage)},on:{\"keyup\":function($event){if(!('button' in $event)&&_vm._k($event.keyCode,\"enter\",13,$event.key,\"Enter\")){ return null; }_vm.submit(_vm.currentMessage)},\"input\":function($event){if($event.target.composing){ return; }_vm.currentMessage=$event.target.value}}})])])]):_c('div',{staticClass:\"chat-panel\"},[_c('div',{staticClass:\"panel panel-default\"},[_c('div',{staticClass:\"panel-heading stub timeline-heading chat-heading\",on:{\"click\":function($event){$event.stopPropagation();$event.preventDefault();return _vm.togglePanel($event)}}},[_c('div',{staticClass:\"title\"},[_c('i',{staticClass:\"icon-comment-empty\"}),_vm._v(\"\\n \"+_vm._s(_vm.$t('chat.title'))+\"\\n \")])])])])}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:\"panel panel-default\"},[_c('div',{staticClass:\"panel-heading\"},[_vm._v(\"\\n \"+_vm._s(_vm.$t('who_to_follow.who_to_follow'))+\"\\n \")]),_vm._v(\" \"),_c('div',{staticClass:\"panel-body\"},_vm._l((_vm.users),function(user){return _c('FollowCard',{key:user.id,staticClass:\"list-item\",attrs:{\"user\":user}})}),1)])}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:\"instance-specific-panel\"},[_c('div',{staticClass:\"panel panel-default\"},[_c('div',{staticClass:\"panel-body\"},[_c('div',{domProps:{\"innerHTML\":_vm._s(_vm.instanceSpecificPanelContent)}})])])])}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:\"features-panel\"},[_c('div',{staticClass:\"panel panel-default base01-background\"},[_c('div',{staticClass:\"panel-heading timeline-heading base02-background base04\"},[_c('div',{staticClass:\"title\"},[_vm._v(\"\\n \"+_vm._s(_vm.$t('features_panel.title'))+\"\\n \")])]),_vm._v(\" \"),_c('div',{staticClass:\"panel-body features-panel\"},[_c('ul',[(_vm.chat)?_c('li',[_vm._v(\"\\n \"+_vm._s(_vm.$t('features_panel.chat'))+\"\\n \")]):_vm._e(),_vm._v(\" \"),(_vm.gopher)?_c('li',[_vm._v(\"\\n \"+_vm._s(_vm.$t('features_panel.gopher'))+\"\\n \")]):_vm._e(),_vm._v(\" \"),(_vm.whoToFollow)?_c('li',[_vm._v(\"\\n \"+_vm._s(_vm.$t('features_panel.who_to_follow'))+\"\\n \")]):_vm._e(),_vm._v(\" \"),(_vm.mediaProxy)?_c('li',[_vm._v(\"\\n \"+_vm._s(_vm.$t('features_panel.media_proxy'))+\"\\n \")]):_vm._e(),_vm._v(\" \"),_c('li',[_vm._v(_vm._s(_vm.$t('features_panel.scope_options')))]),_vm._v(\" \"),_c('li',[_vm._v(_vm._s(_vm.$t('features_panel.text_limit'))+\" = \"+_vm._s(_vm.textlimit))])])])])])}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',[_c('div',{staticClass:\"panel panel-default\"},[_c('div',{staticClass:\"panel-body\"},[_c('div',{staticClass:\"tos-content\",domProps:{\"innerHTML\":_vm._s(_vm.content)}})])])])}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:\"sidebar\"},[_c('instance-specific-panel'),_vm._v(\" \"),(_vm.showFeaturesPanel)?_c('features-panel'):_vm._e(),_vm._v(\" \"),_c('terms-of-service-panel')],1)}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:\"panel panel-default\"},[_c('div',{staticClass:\"panel-heading\"},[_vm._v(\"\\n \"+_vm._s(_vm.$t('remote_user_resolver.remote_user_resolver'))+\"\\n \")]),_vm._v(\" \"),_c('div',{staticClass:\"panel-body\"},[_c('p',[_vm._v(\"\\n \"+_vm._s(_vm.$t('remote_user_resolver.searching_for'))+\" @\"+_vm._s(_vm.$route.params.username)+\"@\"+_vm._s(_vm.$route.params.hostname)+\"\\n \")]),_vm._v(\" \"),(_vm.error)?_c('p',[_vm._v(\"\\n \"+_vm._s(_vm.$t('remote_user_resolver.error'))+\"\\n \")]):_vm._e()])])}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:\"user-panel\"},[(_vm.signedIn)?_c('div',{key:\"user-panel\",staticClass:\"panel panel-default signed-in\"},[_c('UserCard',{attrs:{\"user\":_vm.user,\"hide-bio\":true,\"rounded\":\"top\"}}),_vm._v(\" \"),_c('div',{staticClass:\"panel-footer\"},[_c('PostStatusForm')],1)],1):_c('auth-form',{key:\"user-panel\"})],1)}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:\"nav-panel\"},[_c('div',{staticClass:\"panel panel-default\"},[_c('ul',[(_vm.currentUser)?_c('li',[_c('router-link',{attrs:{\"to\":{ name: 'friends' }}},[_vm._v(\"\\n \"+_vm._s(_vm.$t(\"nav.timeline\"))+\"\\n \")])],1):_vm._e(),_vm._v(\" \"),(_vm.currentUser)?_c('li',[_c('router-link',{attrs:{\"to\":{ name: 'interactions', params: { username: _vm.currentUser.screen_name } }}},[_vm._v(\"\\n \"+_vm._s(_vm.$t(\"nav.interactions\"))+\"\\n \")])],1):_vm._e(),_vm._v(\" \"),(_vm.currentUser)?_c('li',[_c('router-link',{attrs:{\"to\":{ name: 'dms', params: { username: _vm.currentUser.screen_name } }}},[_vm._v(\"\\n \"+_vm._s(_vm.$t(\"nav.dms\"))+\"\\n \")])],1):_vm._e(),_vm._v(\" \"),(_vm.currentUser && _vm.currentUser.locked)?_c('li',[_c('router-link',{attrs:{\"to\":{ name: 'friend-requests' }}},[_vm._v(\"\\n \"+_vm._s(_vm.$t(\"nav.friend_requests\"))+\"\\n \"),(_vm.followRequestCount > 0)?_c('span',{staticClass:\"badge follow-request-count\"},[_vm._v(\"\\n \"+_vm._s(_vm.followRequestCount)+\"\\n \")]):_vm._e()])],1):_vm._e(),_vm._v(\" \"),_c('li',[_c('router-link',{attrs:{\"to\":{ name: 'public-timeline' }}},[_vm._v(\"\\n \"+_vm._s(_vm.$t(\"nav.public_tl\"))+\"\\n \")])],1),_vm._v(\" \"),_c('li',[_c('router-link',{attrs:{\"to\":{ name: 'public-external-timeline' }}},[_vm._v(\"\\n \"+_vm._s(_vm.$t(\"nav.twkn\"))+\"\\n \")])],1)])])])}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',[_c('div',{staticClass:\"search-bar-container\"},[(_vm.loading)?_c('i',{staticClass:\"icon-spin4 finder-icon animate-spin-slow\"}):_vm._e(),_vm._v(\" \"),(_vm.hidden)?_c('a',{attrs:{\"href\":\"#\",\"title\":_vm.$t('nav.search')}},[_c('i',{staticClass:\"button-icon icon-search\",on:{\"click\":function($event){$event.preventDefault();$event.stopPropagation();return _vm.toggleHidden($event)}}})]):[_c('input',{directives:[{name:\"model\",rawName:\"v-model\",value:(_vm.searchTerm),expression:\"searchTerm\"}],ref:\"searchInput\",staticClass:\"search-bar-input\",attrs:{\"id\":\"search-bar-input\",\"placeholder\":_vm.$t('nav.search'),\"type\":\"text\"},domProps:{\"value\":(_vm.searchTerm)},on:{\"keyup\":function($event){if(!('button' in $event)&&_vm._k($event.keyCode,\"enter\",13,$event.key,\"Enter\")){ return null; }_vm.find(_vm.searchTerm)},\"input\":function($event){if($event.target.composing){ return; }_vm.searchTerm=$event.target.value}}}),_vm._v(\" \"),_c('button',{staticClass:\"btn search-button\",on:{\"click\":function($event){_vm.find(_vm.searchTerm)}}},[_c('i',{staticClass:\"icon-search\"})]),_vm._v(\" \"),_c('i',{staticClass:\"button-icon icon-cancel\",on:{\"click\":function($event){$event.preventDefault();$event.stopPropagation();return _vm.toggleHidden($event)}}})]],2)])}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:\"who-to-follow-panel\"},[_c('div',{staticClass:\"panel panel-default base01-background\"},[_c('div',{staticClass:\"panel-heading timeline-heading base02-background base04\"},[_c('div',{staticClass:\"title\"},[_vm._v(\"\\n \"+_vm._s(_vm.$t('who_to_follow.who_to_follow'))+\"\\n \")])]),_vm._v(\" \"),_c('div',{staticClass:\"who-to-follow\"},[_vm._l((_vm.usersToFollow),function(user){return _c('p',{key:user.id,staticClass:\"who-to-follow-items\"},[_c('img',{attrs:{\"src\":user.img}}),_vm._v(\" \"),_c('router-link',{attrs:{\"to\":_vm.userProfileLink(user.id, user.name)}},[_vm._v(\"\\n \"+_vm._s(user.name)+\"\\n \")]),_c('br')],1)}),_vm._v(\" \"),_c('p',{staticClass:\"who-to-follow-more\"},[_c('router-link',{attrs:{\"to\":{ name: 'who-to-follow' }}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('who_to_follow.more'))+\"\\n \")])],1)],2)])])}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{directives:[{name:\"show\",rawName:\"v-show\",value:(_vm.isOpen),expression:\"isOpen\"},{name:\"body-scroll-lock\",rawName:\"v-body-scroll-lock\",value:(_vm.isOpen),expression:\"isOpen\"}],staticClass:\"modal-view\",on:{\"click\":function($event){if($event.target !== $event.currentTarget){ return null; }_vm.$emit('backdropClicked')}}},[_vm._t(\"default\")],2)}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return (_vm.showing)?_c('Modal',{staticClass:\"media-modal-view\",on:{\"backdropClicked\":_vm.hide}},[(_vm.type === 'image')?_c('img',{staticClass:\"modal-image\",attrs:{\"src\":_vm.currentMedia.url},on:{\"touchstart\":function($event){$event.stopPropagation();return _vm.mediaTouchStart($event)},\"touchmove\":function($event){$event.stopPropagation();return _vm.mediaTouchMove($event)}}}):_vm._e(),_vm._v(\" \"),(_vm.type === 'video')?_c('VideoAttachment',{staticClass:\"modal-image\",attrs:{\"attachment\":_vm.currentMedia,\"controls\":true},nativeOn:{\"click\":function($event){$event.stopPropagation();}}}):_vm._e(),_vm._v(\" \"),(_vm.canNavigate)?_c('button',{staticClass:\"modal-view-button-arrow modal-view-button-arrow--prev\",attrs:{\"title\":_vm.$t('media_modal.previous')},on:{\"click\":function($event){$event.stopPropagation();$event.preventDefault();return _vm.goPrev($event)}}},[_c('i',{staticClass:\"icon-left-open arrow-icon\"})]):_vm._e(),_vm._v(\" \"),(_vm.canNavigate)?_c('button',{staticClass:\"modal-view-button-arrow modal-view-button-arrow--next\",attrs:{\"title\":_vm.$t('media_modal.next')},on:{\"click\":function($event){$event.stopPropagation();$event.preventDefault();return _vm.goNext($event)}}},[_c('i',{staticClass:\"icon-right-open arrow-icon\"})]):_vm._e()],1):_vm._e()}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:\"side-drawer-container\",class:{ 'side-drawer-container-closed': _vm.closed, 'side-drawer-container-open': !_vm.closed }},[_c('div',{staticClass:\"side-drawer-darken\",class:{ 'side-drawer-darken-closed': _vm.closed}}),_vm._v(\" \"),_c('div',{staticClass:\"side-drawer\",class:{'side-drawer-closed': _vm.closed},on:{\"touchstart\":_vm.touchStart,\"touchmove\":_vm.touchMove}},[_c('div',{staticClass:\"side-drawer-heading\",on:{\"click\":_vm.toggleDrawer}},[(_vm.currentUser)?_c('UserCard',{attrs:{\"user\":_vm.currentUser,\"hide-bio\":true}}):_c('div',{staticClass:\"side-drawer-logo-wrapper\"},[_c('img',{attrs:{\"src\":_vm.logo}}),_vm._v(\" \"),_c('span',[_vm._v(_vm._s(_vm.sitename))])])],1),_vm._v(\" \"),_c('ul',[(!_vm.currentUser)?_c('li',{on:{\"click\":_vm.toggleDrawer}},[_c('router-link',{attrs:{\"to\":{ name: 'login' }}},[_vm._v(\"\\n \"+_vm._s(_vm.$t(\"login.login\"))+\"\\n \")])],1):_vm._e(),_vm._v(\" \"),(_vm.currentUser)?_c('li',{on:{\"click\":_vm.toggleDrawer}},[_c('router-link',{attrs:{\"to\":{ name: 'dms', params: { username: _vm.currentUser.screen_name } }}},[_vm._v(\"\\n \"+_vm._s(_vm.$t(\"nav.dms\"))+\"\\n \")])],1):_vm._e(),_vm._v(\" \"),(_vm.currentUser)?_c('li',{on:{\"click\":_vm.toggleDrawer}},[_c('router-link',{attrs:{\"to\":{ name: 'interactions', params: { username: _vm.currentUser.screen_name } }}},[_vm._v(\"\\n \"+_vm._s(_vm.$t(\"nav.interactions\"))+\"\\n \")])],1):_vm._e()]),_vm._v(\" \"),_c('ul',[(_vm.currentUser)?_c('li',{on:{\"click\":_vm.toggleDrawer}},[_c('router-link',{attrs:{\"to\":{ name: 'friends' }}},[_vm._v(\"\\n \"+_vm._s(_vm.$t(\"nav.timeline\"))+\"\\n \")])],1):_vm._e(),_vm._v(\" \"),(_vm.currentUser && _vm.currentUser.locked)?_c('li',{on:{\"click\":_vm.toggleDrawer}},[_c('router-link',{attrs:{\"to\":\"/friend-requests\"}},[_vm._v(\"\\n \"+_vm._s(_vm.$t(\"nav.friend_requests\"))+\"\\n \"),(_vm.followRequestCount > 0)?_c('span',{staticClass:\"badge follow-request-count\"},[_vm._v(\"\\n \"+_vm._s(_vm.followRequestCount)+\"\\n \")]):_vm._e()])],1):_vm._e(),_vm._v(\" \"),_c('li',{on:{\"click\":_vm.toggleDrawer}},[_c('router-link',{attrs:{\"to\":\"/main/public\"}},[_vm._v(\"\\n \"+_vm._s(_vm.$t(\"nav.public_tl\"))+\"\\n \")])],1),_vm._v(\" \"),_c('li',{on:{\"click\":_vm.toggleDrawer}},[_c('router-link',{attrs:{\"to\":\"/main/all\"}},[_vm._v(\"\\n \"+_vm._s(_vm.$t(\"nav.twkn\"))+\"\\n \")])],1),_vm._v(\" \"),(_vm.currentUser && _vm.chat)?_c('li',{on:{\"click\":_vm.toggleDrawer}},[_c('router-link',{attrs:{\"to\":{ name: 'chat' }}},[_vm._v(\"\\n \"+_vm._s(_vm.$t(\"nav.chat\"))+\"\\n \")])],1):_vm._e()]),_vm._v(\" \"),_c('ul',[_c('li',{on:{\"click\":_vm.toggleDrawer}},[_c('router-link',{attrs:{\"to\":{ name: 'search' }}},[_vm._v(\"\\n \"+_vm._s(_vm.$t(\"nav.search\"))+\"\\n \")])],1),_vm._v(\" \"),(_vm.currentUser && _vm.suggestionsEnabled)?_c('li',{on:{\"click\":_vm.toggleDrawer}},[_c('router-link',{attrs:{\"to\":{ name: 'who-to-follow' }}},[_vm._v(\"\\n \"+_vm._s(_vm.$t(\"nav.who_to_follow\"))+\"\\n \")])],1):_vm._e(),_vm._v(\" \"),_c('li',{on:{\"click\":_vm.toggleDrawer}},[_c('router-link',{attrs:{\"to\":{ name: 'settings' }}},[_vm._v(\"\\n \"+_vm._s(_vm.$t(\"settings.settings\"))+\"\\n \")])],1),_vm._v(\" \"),_c('li',{on:{\"click\":_vm.toggleDrawer}},[_c('router-link',{attrs:{\"to\":{ name: 'about'}}},[_vm._v(\"\\n \"+_vm._s(_vm.$t(\"nav.about\"))+\"\\n \")])],1),_vm._v(\" \"),(_vm.currentUser && _vm.currentUser.role === 'admin')?_c('li',{on:{\"click\":_vm.toggleDrawer}},[_c('a',{attrs:{\"href\":\"/pleroma/admin/#/login-pleroma\",\"target\":\"_blank\"}},[_vm._v(\"\\n \"+_vm._s(_vm.$t(\"nav.administration\"))+\"\\n \")])]):_vm._e(),_vm._v(\" \"),(_vm.currentUser)?_c('li',{on:{\"click\":_vm.toggleDrawer}},[_c('a',{attrs:{\"href\":\"#\"},on:{\"click\":_vm.doLogout}},[_vm._v(\"\\n \"+_vm._s(_vm.$t(\"login.logout\"))+\"\\n \")])]):_vm._e()])]),_vm._v(\" \"),_c('div',{staticClass:\"side-drawer-click-outside\",class:{'side-drawer-click-outside-closed': _vm.closed},on:{\"click\":function($event){$event.stopPropagation();$event.preventDefault();return _vm.toggleDrawer($event)}}})])}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return (_vm.isLoggedIn)?_c('div',[_c('button',{staticClass:\"new-status-button\",class:{ 'hidden': _vm.isHidden },on:{\"click\":_vm.openPostForm}},[_c('i',{staticClass:\"icon-edit\"})])]):_vm._e()}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',[_c('nav',{staticClass:\"nav-bar container\",attrs:{\"id\":\"nav\"}},[_c('div',{staticClass:\"mobile-inner-nav\",on:{\"click\":function($event){_vm.scrollToTop()}}},[_c('div',{staticClass:\"item\"},[_c('a',{staticClass:\"mobile-nav-button\",attrs:{\"href\":\"#\"},on:{\"click\":function($event){$event.stopPropagation();$event.preventDefault();_vm.toggleMobileSidebar()}}},[_c('i',{staticClass:\"button-icon icon-menu\"})]),_vm._v(\" \"),_c('router-link',{staticClass:\"site-name\",attrs:{\"to\":{ name: 'root' },\"active-class\":\"home\"}},[_vm._v(\"\\n \"+_vm._s(_vm.sitename)+\"\\n \")])],1),_vm._v(\" \"),_c('div',{staticClass:\"item right\"},[(_vm.currentUser)?_c('a',{staticClass:\"mobile-nav-button\",attrs:{\"href\":\"#\"},on:{\"click\":function($event){$event.stopPropagation();$event.preventDefault();_vm.openMobileNotifications()}}},[_c('i',{staticClass:\"button-icon icon-bell-alt\"}),_vm._v(\" \"),(_vm.unseenNotificationsCount)?_c('div',{staticClass:\"alert-dot\"}):_vm._e()]):_vm._e()])])]),_vm._v(\" \"),(_vm.currentUser)?_c('div',{staticClass:\"mobile-notifications-drawer\",class:{ 'closed': !_vm.notificationsOpen },on:{\"touchstart\":function($event){$event.stopPropagation();return _vm.notificationsTouchStart($event)},\"touchmove\":function($event){$event.stopPropagation();return _vm.notificationsTouchMove($event)}}},[_c('div',{staticClass:\"mobile-notifications-header\"},[_c('span',{staticClass:\"title\"},[_vm._v(_vm._s(_vm.$t('notifications.notifications')))]),_vm._v(\" \"),_c('a',{staticClass:\"mobile-nav-button\",on:{\"click\":function($event){$event.stopPropagation();$event.preventDefault();_vm.closeMobileNotifications()}}},[_c('i',{staticClass:\"button-icon icon-cancel\"})])]),_vm._v(\" \"),_c('div',{staticClass:\"mobile-notifications\",on:{\"scroll\":_vm.onScroll}},[_c('Notifications',{ref:\"notifications\",attrs:{\"no-heading\":true}})],1)]):_vm._e(),_vm._v(\" \"),_c('SideDrawer',{ref:\"sideDrawer\",attrs:{\"logout\":_vm.logout}})],1)}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return (_vm.isOpen)?_c('Modal',{on:{\"backdropClicked\":_vm.closeModal}},[_c('div',{staticClass:\"user-reporting-panel panel\"},[_c('div',{staticClass:\"panel-heading\"},[_c('div',{staticClass:\"title\"},[_vm._v(\"\\n \"+_vm._s(_vm.$t('user_reporting.title', [_vm.user.screen_name]))+\"\\n \")])]),_vm._v(\" \"),_c('div',{staticClass:\"panel-body\"},[_c('div',{staticClass:\"user-reporting-panel-left\"},[_c('div',[_c('p',[_vm._v(_vm._s(_vm.$t('user_reporting.add_comment_description')))]),_vm._v(\" \"),_c('textarea',{directives:[{name:\"model\",rawName:\"v-model\",value:(_vm.comment),expression:\"comment\"}],staticClass:\"form-control\",attrs:{\"placeholder\":_vm.$t('user_reporting.additional_comments'),\"rows\":\"1\"},domProps:{\"value\":(_vm.comment)},on:{\"input\":[function($event){if($event.target.composing){ return; }_vm.comment=$event.target.value},_vm.resize]}})]),_vm._v(\" \"),(!_vm.user.is_local)?_c('div',[_c('p',[_vm._v(_vm._s(_vm.$t('user_reporting.forward_description')))]),_vm._v(\" \"),_c('Checkbox',{model:{value:(_vm.forward),callback:function ($$v) {_vm.forward=$$v},expression:\"forward\"}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('user_reporting.forward_to', [_vm.remoteInstance]))+\"\\n \")])],1):_vm._e(),_vm._v(\" \"),_c('div',[_c('button',{staticClass:\"btn btn-default\",attrs:{\"disabled\":_vm.processing},on:{\"click\":_vm.reportUser}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('user_reporting.submit'))+\"\\n \")]),_vm._v(\" \"),(_vm.error)?_c('div',{staticClass:\"alert error\"},[_vm._v(\"\\n \"+_vm._s(_vm.$t('user_reporting.generic_error'))+\"\\n \")]):_vm._e()])]),_vm._v(\" \"),_c('div',{staticClass:\"user-reporting-panel-right\"},[_c('List',{attrs:{\"items\":_vm.statuses},scopedSlots:_vm._u([{key:\"item\",fn:function(ref){\nvar item = ref.item;\nreturn [_c('div',{staticClass:\"status-fadein user-reporting-panel-sitem\"},[_c('Status',{attrs:{\"in-conversation\":false,\"focused\":false,\"statusoid\":item}}),_vm._v(\" \"),_c('Checkbox',{attrs:{\"checked\":_vm.isChecked(item.id)},on:{\"change\":function (checked) { return _vm.toggleStatus(checked, item.id); }}})],1)]}}])})],1)])])]):_vm._e()}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return (_vm.isLoggedIn && !_vm.resettingForm)?_c('Modal',{staticClass:\"post-form-modal-view\",attrs:{\"is-open\":_vm.modalActivated},on:{\"backdropClicked\":_vm.closeModal}},[_c('div',{staticClass:\"post-form-modal-panel panel\"},[_c('div',{staticClass:\"panel-heading\"},[_vm._v(\"\\n \"+_vm._s(_vm.$t('post_status.new_status'))+\"\\n \")]),_vm._v(\" \"),_c('PostStatusForm',_vm._b({staticClass:\"panel-body\",on:{\"posted\":_vm.closeModal}},'PostStatusForm',_vm.params,false))],1)]):_vm._e()}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{style:(_vm.bgAppStyle),attrs:{\"id\":\"app\"}},[_c('div',{staticClass:\"app-bg-wrapper\",style:(_vm.bgStyle),attrs:{\"id\":\"app_bg_wrapper\"}}),_vm._v(\" \"),(_vm.isMobileLayout)?_c('MobileNav'):_c('nav',{staticClass:\"nav-bar container\",attrs:{\"id\":\"nav\"},on:{\"click\":function($event){_vm.scrollToTop()}}},[_c('div',{staticClass:\"inner-nav\"},[_c('div',{staticClass:\"logo\",style:(_vm.logoBgStyle)},[_c('div',{staticClass:\"mask\",style:(_vm.logoMaskStyle)}),_vm._v(\" \"),_c('img',{style:(_vm.logoStyle),attrs:{\"src\":_vm.logo}})]),_vm._v(\" \"),_c('div',{staticClass:\"item\"},[_c('router-link',{staticClass:\"site-name\",attrs:{\"to\":{ name: 'root' },\"active-class\":\"home\"}},[_vm._v(\"\\n \"+_vm._s(_vm.sitename)+\"\\n \")])],1),_vm._v(\" \"),_c('div',{staticClass:\"item right\"},[_c('search-bar',{staticClass:\"nav-icon mobile-hidden\",on:{\"toggled\":_vm.onSearchBarToggled},nativeOn:{\"click\":function($event){$event.stopPropagation();}}}),_vm._v(\" \"),_c('router-link',{staticClass:\"mobile-hidden\",attrs:{\"to\":{ name: 'settings'}}},[_c('i',{staticClass:\"button-icon icon-cog nav-icon\",attrs:{\"title\":_vm.$t('nav.preferences')}})]),_vm._v(\" \"),(_vm.currentUser && _vm.currentUser.role === 'admin')?_c('a',{staticClass:\"mobile-hidden\",attrs:{\"href\":\"/pleroma/admin/#/login-pleroma\",\"target\":\"_blank\"}},[_c('i',{staticClass:\"button-icon icon-gauge nav-icon\",attrs:{\"title\":_vm.$t('nav.administration')}})]):_vm._e(),_vm._v(\" \"),(_vm.currentUser)?_c('a',{staticClass:\"mobile-hidden\",attrs:{\"href\":\"#\"},on:{\"click\":function($event){$event.preventDefault();return _vm.logout($event)}}},[_c('i',{staticClass:\"button-icon icon-logout nav-icon\",attrs:{\"title\":_vm.$t('login.logout')}})]):_vm._e()],1)])]),_vm._v(\" \"),_c('div',{staticClass:\"container\",attrs:{\"id\":\"content\"}},[_c('div',{staticClass:\"sidebar-flexer mobile-hidden\"},[_c('div',{staticClass:\"sidebar-bounds\"},[_c('div',{staticClass:\"sidebar-scroller\"},[_c('div',{staticClass:\"sidebar\"},[_c('user-panel'),_vm._v(\" \"),(!_vm.isMobileLayout)?_c('div',[_c('nav-panel'),_vm._v(\" \"),(_vm.showInstanceSpecificPanel)?_c('instance-specific-panel'):_vm._e(),_vm._v(\" \"),(!_vm.currentUser && _vm.showFeaturesPanel)?_c('features-panel'):_vm._e(),_vm._v(\" \"),(_vm.currentUser && _vm.suggestionsEnabled)?_c('who-to-follow-panel'):_vm._e(),_vm._v(\" \"),(_vm.currentUser)?_c('notifications'):_vm._e()],1):_vm._e()],1)])])]),_vm._v(\" \"),_c('div',{staticClass:\"main\"},[(!_vm.currentUser)?_c('div',{staticClass:\"login-hint panel panel-default\"},[_c('router-link',{staticClass:\"panel-body\",attrs:{\"to\":{ name: 'login' }}},[_vm._v(\"\\n \"+_vm._s(_vm.$t(\"login.hint\"))+\"\\n \")])],1):_vm._e(),_vm._v(\" \"),_c('transition',{attrs:{\"name\":\"fade\"}},[_c('router-view')],1)],1),_vm._v(\" \"),_c('media-modal')],1),_vm._v(\" \"),(_vm.currentUser && _vm.chat)?_c('chat-panel',{staticClass:\"floating-chat mobile-hidden\",attrs:{\"floating\":true}}):_vm._e(),_vm._v(\" \"),_c('MobilePostStatusButton'),_vm._v(\" \"),_c('UserReportingModal'),_vm._v(\" \"),_c('PostStatusModal'),_vm._v(\" \"),_c('portal-target',{attrs:{\"name\":\"modal\"}})],1)}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","import { map } from 'lodash'\nimport apiService from '../api/api.service.js'\n\nconst postStatus = ({ store, status, spoilerText, visibility, sensitive, poll, media = [], inReplyToStatusId = undefined, contentType = 'text/plain' }) => {\n const mediaIds = map(media, 'id')\n\n return apiService.postStatus({\n credentials: store.state.users.currentUser.credentials,\n status,\n spoilerText,\n visibility,\n sensitive,\n mediaIds,\n inReplyToStatusId,\n contentType,\n poll })\n .then((data) => {\n if (!data.error) {\n store.dispatch('addNewStatuses', {\n statuses: [data],\n timeline: 'friends',\n showImmediately: true,\n noIdUpdate: true // To prevent missing notices on next pull.\n })\n }\n return data\n })\n .catch((err) => {\n return {\n error: err.message\n }\n })\n}\n\nconst uploadMedia = ({ store, formData }) => {\n const credentials = store.state.users.currentUser.credentials\n\n return apiService.uploadMedia({ credentials, formData })\n}\n\nconst statusPosterService = {\n postStatus,\n uploadMedia\n}\n\nexport default statusPosterService\n","import { camelCase } from 'lodash'\n\nimport apiService from '../api/api.service.js'\n\nconst update = ({ store, statuses, timeline, showImmediately, userId }) => {\n const ccTimeline = camelCase(timeline)\n\n store.dispatch('setError', { value: false })\n\n store.dispatch('addNewStatuses', {\n timeline: ccTimeline,\n userId,\n statuses,\n showImmediately\n })\n}\n\nconst fetchAndUpdate = ({\n store,\n credentials,\n timeline = 'friends',\n older = false,\n showImmediately = false,\n userId = false,\n tag = false,\n until\n}) => {\n const args = { timeline, credentials }\n const rootState = store.rootState || store.state\n const { getters } = store\n const timelineData = rootState.statuses.timelines[camelCase(timeline)]\n const hideMutedPosts = getters.mergedConfig.hideMutedPosts\n\n if (older) {\n args['until'] = until || timelineData.minId\n } else {\n args['since'] = timelineData.maxId\n }\n\n args['userId'] = userId\n args['tag'] = tag\n args['withMuted'] = !hideMutedPosts\n\n const numStatusesBeforeFetch = timelineData.statuses.length\n\n return apiService.fetchTimeline(args)\n .then((statuses) => {\n if (!older && statuses.length >= 20 && !timelineData.loading && numStatusesBeforeFetch > 0) {\n store.dispatch('queueFlush', { timeline: timeline, id: timelineData.maxId })\n }\n update({ store, statuses, timeline, showImmediately, userId })\n return statuses\n }, () => store.dispatch('setError', { value: true }))\n}\n\nconst startFetching = ({ timeline = 'friends', credentials, store, userId = false, tag = false }) => {\n const rootState = store.rootState || store.state\n const timelineData = rootState.statuses.timelines[camelCase(timeline)]\n const showImmediately = timelineData.visibleStatuses.length === 0\n timelineData.userId = userId\n fetchAndUpdate({ timeline, credentials, store, showImmediately, userId, tag })\n const boundFetchAndUpdate = () => fetchAndUpdate({ timeline, credentials, store, userId, tag })\n return setInterval(boundFetchAndUpdate, 10000)\n}\nconst timelineFetcher = {\n fetchAndUpdate,\n startFetching\n}\n\nexport default timelineFetcher\n","import apiService from '../api/api.service.js'\n\nconst update = ({ store, notifications, older }) => {\n store.dispatch('setNotificationsError', { value: false })\n\n store.dispatch('addNewNotifications', { notifications, older })\n}\n\nconst fetchAndUpdate = ({ store, credentials, older = false }) => {\n const args = { credentials }\n const { getters } = store\n const rootState = store.rootState || store.state\n const timelineData = rootState.statuses.notifications\n const hideMutedPosts = getters.mergedConfig.hideMutedPosts\n\n args['withMuted'] = !hideMutedPosts\n\n args['timeline'] = 'notifications'\n if (older) {\n if (timelineData.minId !== Number.POSITIVE_INFINITY) {\n args['until'] = timelineData.minId\n }\n return fetchNotifications({ store, args, older })\n } else {\n // fetch new notifications\n if (timelineData.maxId !== Number.POSITIVE_INFINITY) {\n args['since'] = timelineData.maxId\n }\n const result = fetchNotifications({ store, args, older })\n\n // load unread notifications repeatedly to provide consistency between browser tabs\n const notifications = timelineData.data\n const unread = notifications.filter(n => !n.seen).map(n => n.id)\n if (unread.length) {\n args['since'] = Math.min(...unread)\n fetchNotifications({ store, args, older })\n }\n\n return result\n }\n}\n\nconst fetchNotifications = ({ store, args, older }) => {\n return apiService.fetchTimeline(args)\n .then((notifications) => {\n update({ store, notifications, older })\n return notifications\n }, () => store.dispatch('setNotificationsError', { value: true }))\n .catch(() => store.dispatch('setNotificationsError', { value: true }))\n}\n\nconst startFetching = ({ credentials, store }) => {\n fetchAndUpdate({ credentials, store })\n const boundFetchAndUpdate = () => fetchAndUpdate({ credentials, store })\n // Initially there's set flag to silence all desktop notifications so\n // that there won't spam of them when user just opened up the FE we\n // reset that flag after a while to show new notifications once again.\n setTimeout(() => store.dispatch('setNotificationsSilence', false), 10000)\n return setInterval(boundFetchAndUpdate, 10000)\n}\n\nconst notificationsFetcher = {\n fetchAndUpdate,\n startFetching\n}\n\nexport default notificationsFetcher\n","// When contributing, please sort JSON before committing so it would be easier to see what's missing and what's being added compared to English and other languages. It's not obligatory, but just an advice.\n// To sort json use jq https://stedolan.github.io/jq and invoke it like `jq -S . xx.json > xx.sorted.json`, AFAIK, there's no inplace edit option like in sed\n// Also, when adding a new language to \"messages\" variable, please do it alphabetically by language code so that users can search or check their custom language easily.\n\n// For anyone contributing to old huge messages.js and in need to quickly convert it to JSON\n// sed command for converting currently formatted JS to JSON:\n// sed -i -e \"s/'//gm\" -e 's/\"/\\\\\"/gm' -re 's/^( +)(.+?): ((.+?))?(,?)(\\{?)$/\\1\"\\2\": \"\\4\"/gm' -e 's/\\\"\\{\\\"/{/g' -e 's/,\"$/\",/g' file.json\n// There's only problem that apostrophe character ' gets replaced by \\\\ so you have to fix it manually, sorry.\n\nconst messages = {\n ar: require('./ar.json'),\n ca: require('./ca.json'),\n cs: require('./cs.json'),\n de: require('./de.json'),\n en: require('./en.json'),\n eo: require('./eo.json'),\n es: require('./es.json'),\n et: require('./et.json'),\n eu: require('./eu.json'),\n fi: require('./fi.json'),\n fr: require('./fr.json'),\n ga: require('./ga.json'),\n he: require('./he.json'),\n hu: require('./hu.json'),\n it: require('./it.json'),\n ja: require('./ja.json'),\n ja_pedantic: require('./ja_pedantic.json'),\n ko: require('./ko.json'),\n nb: require('./nb.json'),\n nl: require('./nl.json'),\n oc: require('./oc.json'),\n pl: require('./pl.json'),\n pt: require('./pt.json'),\n ro: require('./ro.json'),\n ru: require('./ru.json'),\n te: require('./te.json'),\n zh: require('./zh.json')\n}\n\nexport default messages\n","function injectStyle (context) {\n require(\"!!vue-style-loader!css-loader?minimize!../../../node_modules/vue-loader/lib/style-compiler/index?{\\\"optionsId\\\":\\\"0\\\",\\\"vue\\\":true,\\\"scoped\\\":false,\\\"sourceMap\\\":false}!sass-loader!../../../node_modules/vue-loader/lib/selector?type=styles&index=0!./attachment.vue\")\n}\n/* script */\nexport * from \"!!babel-loader!./attachment.js\"\nimport __vue_script__ from \"!!babel-loader!./attachment.js\"/* template */\nimport {render as __vue_render__, staticRenderFns as __vue_static_render_fns__} from \"!!../../../node_modules/vue-loader/lib/template-compiler/index?{\\\"id\\\":\\\"data-v-47ab0ca0\\\",\\\"hasScoped\\\":false,\\\"optionsId\\\":\\\"0\\\",\\\"buble\\\":{\\\"transforms\\\":{}}}!../../../node_modules/vue-loader/lib/selector?type=template&index=0!./attachment.vue\"\n/* template functional */\nvar __vue_template_functional__ = false\n/* styles */\nvar __vue_styles__ = injectStyle\n/* scopeId */\nvar __vue_scopeId__ = null\n/* moduleIdentifier (server only) */\nvar __vue_module_identifier__ = null\nimport normalizeComponent from \"!../../../node_modules/vue-loader/lib/runtime/component-normalizer\"\nvar Component = normalizeComponent(\n __vue_script__,\n __vue_render__,\n __vue_static_render_fns__,\n __vue_template_functional__,\n __vue_styles__,\n __vue_scopeId__,\n __vue_module_identifier__\n)\n\nexport default Component.exports\n","/* script */\nexport * from \"!!babel-loader!./video_attachment.js\"\nimport __vue_script__ from \"!!babel-loader!./video_attachment.js\"/* template */\nimport {render as __vue_render__, staticRenderFns as __vue_static_render_fns__} from \"!!../../../node_modules/vue-loader/lib/template-compiler/index?{\\\"id\\\":\\\"data-v-6fce6a82\\\",\\\"hasScoped\\\":false,\\\"optionsId\\\":\\\"0\\\",\\\"buble\\\":{\\\"transforms\\\":{}}}!../../../node_modules/vue-loader/lib/selector?type=template&index=0!./video_attachment.vue\"\n/* template functional */\nvar __vue_template_functional__ = false\n/* styles */\nvar __vue_styles__ = null\n/* scopeId */\nvar __vue_scopeId__ = null\n/* moduleIdentifier (server only) */\nvar __vue_module_identifier__ = null\nimport normalizeComponent from \"!../../../node_modules/vue-loader/lib/runtime/component-normalizer\"\nvar Component = normalizeComponent(\n __vue_script__,\n __vue_render__,\n __vue_static_render_fns__,\n __vue_template_functional__,\n __vue_styles__,\n __vue_scopeId__,\n __vue_module_identifier__\n)\n\nexport default Component.exports\n","export const SECOND = 1000\nexport const MINUTE = 60 * SECOND\nexport const HOUR = 60 * MINUTE\nexport const DAY = 24 * HOUR\nexport const WEEK = 7 * DAY\nexport const MONTH = 30 * DAY\nexport const YEAR = 365.25 * DAY\n\nexport const relativeTime = (date, nowThreshold = 1) => {\n if (typeof date === 'string') date = Date.parse(date)\n const round = Date.now() > date ? Math.floor : Math.ceil\n const d = Math.abs(Date.now() - date)\n let r = { num: round(d / YEAR), key: 'time.years' }\n if (d < nowThreshold * SECOND) {\n r.num = 0\n r.key = 'time.now'\n } else if (d < MINUTE) {\n r.num = round(d / SECOND)\n r.key = 'time.seconds'\n } else if (d < HOUR) {\n r.num = round(d / MINUTE)\n r.key = 'time.minutes'\n } else if (d < DAY) {\n r.num = round(d / HOUR)\n r.key = 'time.hours'\n } else if (d < WEEK) {\n r.num = round(d / DAY)\n r.key = 'time.days'\n } else if (d < MONTH) {\n r.num = round(d / WEEK)\n r.key = 'time.weeks'\n } else if (d < YEAR) {\n r.num = round(d / MONTH)\n r.key = 'time.months'\n }\n // Remove plural form when singular\n if (r.num === 1) r.key = r.key.slice(0, -1)\n return r\n}\n\nexport const relativeTimeShort = (date, nowThreshold = 1) => {\n const r = relativeTime(date, nowThreshold)\n r.key += '_short'\n return r\n}\n","const fileSizeFormat = (num) => {\n var exponent\n var unit\n var units = ['B', 'KiB', 'MiB', 'GiB', 'TiB']\n if (num < 1) {\n return num + ' ' + units[0]\n }\n\n exponent = Math.min(Math.floor(Math.log(num) / Math.log(1024)), units.length - 1)\n num = (num / Math.pow(1024, exponent)).toFixed(2) * 1\n unit = units[exponent]\n return { num: num, unit: unit }\n}\nconst fileSizeFormatService = {\n fileSizeFormat\n}\nexport default fileSizeFormatService\n","function injectStyle (context) {\n require(\"!!vue-style-loader!css-loader?minimize!../../../node_modules/vue-loader/lib/style-compiler/index?{\\\"optionsId\\\":\\\"0\\\",\\\"vue\\\":true,\\\"scoped\\\":false,\\\"sourceMap\\\":false}!sass-loader!../../../node_modules/vue-loader/lib/selector?type=styles&index=0!./scope_selector.vue\")\n}\n/* script */\nexport * from \"!!babel-loader!./scope_selector.js\"\nimport __vue_script__ from \"!!babel-loader!./scope_selector.js\"/* template */\nimport {render as __vue_render__, staticRenderFns as __vue_static_render_fns__} from \"!!../../../node_modules/vue-loader/lib/template-compiler/index?{\\\"id\\\":\\\"data-v-28e8cbf1\\\",\\\"hasScoped\\\":false,\\\"optionsId\\\":\\\"0\\\",\\\"buble\\\":{\\\"transforms\\\":{}}}!../../../node_modules/vue-loader/lib/selector?type=template&index=0!./scope_selector.vue\"\n/* template functional */\nvar __vue_template_functional__ = false\n/* styles */\nvar __vue_styles__ = injectStyle\n/* scopeId */\nvar __vue_scopeId__ = null\n/* moduleIdentifier (server only) */\nvar __vue_module_identifier__ = null\nimport normalizeComponent from \"!../../../node_modules/vue-loader/lib/runtime/component-normalizer\"\nvar Component = normalizeComponent(\n __vue_script__,\n __vue_render__,\n __vue_static_render_fns__,\n __vue_template_functional__,\n __vue_styles__,\n __vue_scopeId__,\n __vue_module_identifier__\n)\n\nexport default Component.exports\n","function injectStyle (context) {\n require(\"!!vue-style-loader!css-loader?minimize!../../../node_modules/vue-loader/lib/style-compiler/index?{\\\"optionsId\\\":\\\"0\\\",\\\"vue\\\":true,\\\"scoped\\\":false,\\\"sourceMap\\\":false}!sass-loader!../../../node_modules/vue-loader/lib/selector?type=styles&index=0!./emoji_input.vue\")\n}\n/* script */\nexport * from \"!!babel-loader!./emoji_input.js\"\nimport __vue_script__ from \"!!babel-loader!./emoji_input.js\"/* template */\nimport {render as __vue_render__, staticRenderFns as __vue_static_render_fns__} from \"!!../../../node_modules/vue-loader/lib/template-compiler/index?{\\\"id\\\":\\\"data-v-a4078164\\\",\\\"hasScoped\\\":false,\\\"optionsId\\\":\\\"0\\\",\\\"buble\\\":{\\\"transforms\\\":{}}}!../../../node_modules/vue-loader/lib/selector?type=template&index=0!./emoji_input.vue\"\n/* template functional */\nvar __vue_template_functional__ = false\n/* styles */\nvar __vue_styles__ = injectStyle\n/* scopeId */\nvar __vue_scopeId__ = null\n/* moduleIdentifier (server only) */\nvar __vue_module_identifier__ = null\nimport normalizeComponent from \"!../../../node_modules/vue-loader/lib/runtime/component-normalizer\"\nvar Component = normalizeComponent(\n __vue_script__,\n __vue_render__,\n __vue_static_render_fns__,\n __vue_template_functional__,\n __vue_styles__,\n __vue_scopeId__,\n __vue_module_identifier__\n)\n\nexport default Component.exports\n","export const findOffset = (child, parent, { top = 0, left = 0 } = {}, ignorePadding = true) => {\n const result = {\n top: top + child.offsetTop,\n left: left + child.offsetLeft\n }\n if (!ignorePadding && child !== window) {\n const { topPadding, leftPadding } = findPadding(child)\n result.top += ignorePadding ? 0 : topPadding\n result.left += ignorePadding ? 0 : leftPadding\n }\n\n if (child.offsetParent && (parent === window || parent.contains(child.offsetParent) || parent === child.offsetParent)) {\n return findOffset(child.offsetParent, parent, result, false)\n } else {\n if (parent !== window) {\n const { topPadding, leftPadding } = findPadding(parent)\n result.top += topPadding\n result.left += leftPadding\n }\n return result\n }\n}\n\nconst findPadding = (el) => {\n const topPaddingStr = window.getComputedStyle(el)['padding-top']\n const topPadding = Number(topPaddingStr.substring(0, topPaddingStr.length - 2))\n const leftPaddingStr = window.getComputedStyle(el)['padding-left']\n const leftPadding = Number(leftPaddingStr.substring(0, leftPaddingStr.length - 2))\n\n return { topPadding, leftPadding }\n}\n","import { debounce } from 'lodash'\n/**\n * suggest - generates a suggestor function to be used by emoji-input\n * data: object providing source information for specific types of suggestions:\n * data.emoji - optional, an array of all emoji available i.e.\n * (state.instance.emoji + state.instance.customEmoji)\n * data.users - optional, an array of all known users\n * updateUsersList - optional, a function to search and append to users\n *\n * Depending on data present one or both (or none) can be present, so if field\n * doesn't support user linking you can just provide only emoji.\n */\n\nconst debounceUserSearch = debounce((data, input) => {\n data.updateUsersList(input)\n}, 500, { leading: true, trailing: false })\n\nexport default data => input => {\n const firstChar = input[0]\n if (firstChar === ':' && data.emoji) {\n return suggestEmoji(data.emoji)(input)\n }\n if (firstChar === '@' && data.users) {\n return suggestUsers(data)(input)\n }\n return []\n}\n\nexport const suggestEmoji = emojis => input => {\n const noPrefix = input.toLowerCase().substr(1)\n return emojis\n .filter(({ displayText }) => displayText.toLowerCase().startsWith(noPrefix))\n .sort((a, b) => {\n let aScore = 0\n let bScore = 0\n\n // Make custom emojis a priority\n aScore += a.imageUrl ? 10 : 0\n bScore += b.imageUrl ? 10 : 0\n\n // Sort alphabetically\n const alphabetically = a.displayText > b.displayText ? 1 : -1\n\n return bScore - aScore + alphabetically\n })\n}\n\nexport const suggestUsers = data => input => {\n const noPrefix = input.toLowerCase().substr(1)\n const users = data.users\n\n const newUsers = users.filter(\n user =>\n user.screen_name.toLowerCase().startsWith(noPrefix) ||\n user.name.toLowerCase().startsWith(noPrefix)\n\n /* taking only 20 results so that sorting is a bit cheaper, we display\n * only 5 anyway. could be inaccurate, but we ideally we should query\n * backend anyway\n */\n ).slice(0, 20).sort((a, b) => {\n let aScore = 0\n let bScore = 0\n\n // Matches on screen name (i.e. user@instance) makes a priority\n aScore += a.screen_name.toLowerCase().startsWith(noPrefix) ? 2 : 0\n bScore += b.screen_name.toLowerCase().startsWith(noPrefix) ? 2 : 0\n\n // Matches on name takes second priority\n aScore += a.name.toLowerCase().startsWith(noPrefix) ? 1 : 0\n bScore += b.name.toLowerCase().startsWith(noPrefix) ? 1 : 0\n\n const diff = (bScore - aScore) * 10\n\n // Then sort alphabetically\n const nameAlphabetically = a.name > b.name ? 1 : -1\n const screenNameAlphabetically = a.screen_name > b.screen_name ? 1 : -1\n\n return diff + nameAlphabetically + screenNameAlphabetically\n /* eslint-disable camelcase */\n }).map(({ screen_name, name, profile_image_url_original }) => ({\n displayText: screen_name,\n detailText: name,\n imageUrl: profile_image_url_original,\n replacement: '@' + screen_name + ' '\n }))\n\n // BE search users if there are no matches\n if (newUsers.length === 0 && data.updateUsersList) {\n debounceUserSearch(data, noPrefix)\n }\n return newUsers\n /* eslint-enable camelcase */\n}\n","function injectStyle (context) {\n require(\"!!vue-style-loader!css-loader?minimize!../../../node_modules/vue-loader/lib/style-compiler/index?{\\\"optionsId\\\":\\\"0\\\",\\\"vue\\\":true,\\\"scoped\\\":false,\\\"sourceMap\\\":false}!sass-loader!../../../node_modules/vue-loader/lib/selector?type=styles&index=0!./remote_follow.vue\")\n}\n/* script */\nexport * from \"!!babel-loader!./remote_follow.js\"\nimport __vue_script__ from \"!!babel-loader!./remote_follow.js\"/* template */\nimport {render as __vue_render__, staticRenderFns as __vue_static_render_fns__} from \"!!../../../node_modules/vue-loader/lib/template-compiler/index?{\\\"id\\\":\\\"data-v-e95e446e\\\",\\\"hasScoped\\\":false,\\\"optionsId\\\":\\\"0\\\",\\\"buble\\\":{\\\"transforms\\\":{}}}!../../../node_modules/vue-loader/lib/selector?type=template&index=0!./remote_follow.vue\"\n/* template functional */\nvar __vue_template_functional__ = false\n/* styles */\nvar __vue_styles__ = injectStyle\n/* scopeId */\nvar __vue_scopeId__ = null\n/* moduleIdentifier (server only) */\nvar __vue_module_identifier__ = null\nimport normalizeComponent from \"!../../../node_modules/vue-loader/lib/runtime/component-normalizer\"\nvar Component = normalizeComponent(\n __vue_script__,\n __vue_render__,\n __vue_static_render_fns__,\n __vue_template_functional__,\n __vue_styles__,\n __vue_scopeId__,\n __vue_module_identifier__\n)\n\nexport default Component.exports\n","/* script */\nexport * from \"!!babel-loader!./follow_button.js\"\nimport __vue_script__ from \"!!babel-loader!./follow_button.js\"/* template */\nimport {render as __vue_render__, staticRenderFns as __vue_static_render_fns__} from \"!!../../../node_modules/vue-loader/lib/template-compiler/index?{\\\"id\\\":\\\"data-v-3ddddf8d\\\",\\\"hasScoped\\\":false,\\\"optionsId\\\":\\\"0\\\",\\\"buble\\\":{\\\"transforms\\\":{}}}!../../../node_modules/vue-loader/lib/selector?type=template&index=0!./follow_button.vue\"\n/* template functional */\nvar __vue_template_functional__ = false\n/* styles */\nvar __vue_styles__ = null\n/* scopeId */\nvar __vue_scopeId__ = null\n/* moduleIdentifier (server only) */\nvar __vue_module_identifier__ = null\nimport normalizeComponent from \"!../../../node_modules/vue-loader/lib/runtime/component-normalizer\"\nvar Component = normalizeComponent(\n __vue_script__,\n __vue_render__,\n __vue_static_render_fns__,\n __vue_template_functional__,\n __vue_styles__,\n __vue_scopeId__,\n __vue_module_identifier__\n)\n\nexport default Component.exports\n","import { hex2rgb } from '../color_convert/color_convert.js'\nconst highlightStyle = (prefs) => {\n if (prefs === undefined) return\n const { color, type } = prefs\n if (typeof color !== 'string') return\n const rgb = hex2rgb(color)\n if (rgb == null) return\n const solidColor = `rgb(${Math.floor(rgb.r)}, ${Math.floor(rgb.g)}, ${Math.floor(rgb.b)})`\n const tintColor = `rgba(${Math.floor(rgb.r)}, ${Math.floor(rgb.g)}, ${Math.floor(rgb.b)}, .1)`\n const tintColor2 = `rgba(${Math.floor(rgb.r)}, ${Math.floor(rgb.g)}, ${Math.floor(rgb.b)}, .2)`\n if (type === 'striped') {\n return {\n backgroundImage: [\n 'repeating-linear-gradient(135deg,',\n `${tintColor} ,`,\n `${tintColor} 20px,`,\n `${tintColor2} 20px,`,\n `${tintColor2} 40px`\n ].join(' '),\n backgroundPosition: '0 0'\n }\n } else if (type === 'solid') {\n return {\n backgroundColor: tintColor2\n }\n } else if (type === 'side') {\n return {\n backgroundImage: [\n 'linear-gradient(to right,',\n `${solidColor} ,`,\n `${solidColor} 2px,`,\n `transparent 6px`\n ].join(' '),\n backgroundPosition: '0 0'\n }\n }\n}\n\nconst highlightClass = (user) => {\n return 'USER____' + user.screen_name\n .replace(/\\./g, '_')\n .replace(/@/g, '_AT_')\n}\n\nexport {\n highlightClass,\n highlightStyle\n}\n","import isFunction from 'lodash/isFunction'\n\nconst getComponentOptions = (Component) => (isFunction(Component)) ? Component.options : Component\n\nconst getComponentProps = (Component) => getComponentOptions(Component).props\n\nexport {\n getComponentOptions,\n getComponentProps\n}\n","function injectStyle (context) {\n require(\"!!vue-style-loader!css-loader?minimize!../../../node_modules/vue-loader/lib/style-compiler/index?{\\\"optionsId\\\":\\\"0\\\",\\\"vue\\\":true,\\\"scoped\\\":false,\\\"sourceMap\\\":false}!sass-loader!./style_switcher.scss\")\n}\n/* script */\nexport * from \"!!babel-loader!./style_switcher.js\"\nimport __vue_script__ from \"!!babel-loader!./style_switcher.js\"/* template */\nimport {render as __vue_render__, staticRenderFns as __vue_static_render_fns__} from \"!!../../../node_modules/vue-loader/lib/template-compiler/index?{\\\"id\\\":\\\"data-v-1bd287ab\\\",\\\"hasScoped\\\":false,\\\"optionsId\\\":\\\"0\\\",\\\"buble\\\":{\\\"transforms\\\":{}}}!../../../node_modules/vue-loader/lib/selector?type=template&index=0!./style_switcher.vue\"\n/* template functional */\nvar __vue_template_functional__ = false\n/* styles */\nvar __vue_styles__ = injectStyle\n/* scopeId */\nvar __vue_scopeId__ = null\n/* moduleIdentifier (server only) */\nvar __vue_module_identifier__ = null\nimport normalizeComponent from \"!../../../node_modules/vue-loader/lib/runtime/component-normalizer\"\nvar Component = normalizeComponent(\n __vue_script__,\n __vue_render__,\n __vue_static_render_fns__,\n __vue_template_functional__,\n __vue_styles__,\n __vue_scopeId__,\n __vue_module_identifier__\n)\n\nexport default Component.exports\n","function injectStyle (context) {\n require(\"!!vue-style-loader!css-loader?minimize!../../../node_modules/vue-loader/lib/style-compiler/index?{\\\"optionsId\\\":\\\"0\\\",\\\"vue\\\":true,\\\"scoped\\\":false,\\\"sourceMap\\\":false}!sass-loader!../../../node_modules/vue-loader/lib/selector?type=styles&index=0!./color_input.vue\")\n}\n/* script */\nexport * from \"!!babel-loader!../../../node_modules/vue-loader/lib/selector?type=script&index=0!./color_input.vue\"\nimport __vue_script__ from \"!!babel-loader!../../../node_modules/vue-loader/lib/selector?type=script&index=0!./color_input.vue\"\n/* template */\nimport {render as __vue_render__, staticRenderFns as __vue_static_render_fns__} from \"!!../../../node_modules/vue-loader/lib/template-compiler/index?{\\\"id\\\":\\\"data-v-a377bb38\\\",\\\"hasScoped\\\":false,\\\"optionsId\\\":\\\"0\\\",\\\"buble\\\":{\\\"transforms\\\":{}}}!../../../node_modules/vue-loader/lib/selector?type=template&index=0!./color_input.vue\"\n/* template functional */\nvar __vue_template_functional__ = false\n/* styles */\nvar __vue_styles__ = injectStyle\n/* scopeId */\nvar __vue_scopeId__ = null\n/* moduleIdentifier (server only) */\nvar __vue_module_identifier__ = null\nimport normalizeComponent from \"!../../../node_modules/vue-loader/lib/runtime/component-normalizer\"\nvar Component = normalizeComponent(\n __vue_script__,\n __vue_render__,\n __vue_static_render_fns__,\n __vue_template_functional__,\n __vue_styles__,\n __vue_scopeId__,\n __vue_module_identifier__\n)\n\nexport default Component.exports\n","/* script */\nexport * from \"!!babel-loader!../../../node_modules/vue-loader/lib/selector?type=script&index=0!./opacity_input.vue\"\nimport __vue_script__ from \"!!babel-loader!../../../node_modules/vue-loader/lib/selector?type=script&index=0!./opacity_input.vue\"\n/* template */\nimport {render as __vue_render__, staticRenderFns as __vue_static_render_fns__} from \"!!../../../node_modules/vue-loader/lib/template-compiler/index?{\\\"id\\\":\\\"data-v-87056ae2\\\",\\\"hasScoped\\\":false,\\\"optionsId\\\":\\\"0\\\",\\\"buble\\\":{\\\"transforms\\\":{}}}!../../../node_modules/vue-loader/lib/selector?type=template&index=0!./opacity_input.vue\"\n/* template functional */\nvar __vue_template_functional__ = false\n/* styles */\nvar __vue_styles__ = null\n/* scopeId */\nvar __vue_scopeId__ = null\n/* moduleIdentifier (server only) */\nvar __vue_module_identifier__ = null\nimport normalizeComponent from \"!../../../node_modules/vue-loader/lib/runtime/component-normalizer\"\nvar Component = normalizeComponent(\n __vue_script__,\n __vue_render__,\n __vue_static_render_fns__,\n __vue_template_functional__,\n __vue_styles__,\n __vue_scopeId__,\n __vue_module_identifier__\n)\n\nexport default Component.exports\n","/* script */\nexport * from \"!!babel-loader!./confirm.js\"\nimport __vue_script__ from \"!!babel-loader!./confirm.js\"/* template */\nimport {render as __vue_render__, staticRenderFns as __vue_static_render_fns__} from \"!!../../../node_modules/vue-loader/lib/template-compiler/index?{\\\"id\\\":\\\"data-v-20b6e7b3\\\",\\\"hasScoped\\\":false,\\\"optionsId\\\":\\\"0\\\",\\\"buble\\\":{\\\"transforms\\\":{}}}!../../../node_modules/vue-loader/lib/selector?type=template&index=0!./confirm.vue\"\n/* template functional */\nvar __vue_template_functional__ = false\n/* styles */\nvar __vue_styles__ = null\n/* scopeId */\nvar __vue_scopeId__ = null\n/* moduleIdentifier (server only) */\nvar __vue_module_identifier__ = null\nimport normalizeComponent from \"!../../../node_modules/vue-loader/lib/runtime/component-normalizer\"\nvar Component = normalizeComponent(\n __vue_script__,\n __vue_render__,\n __vue_static_render_fns__,\n __vue_template_functional__,\n __vue_styles__,\n __vue_scopeId__,\n __vue_module_identifier__\n)\n\nexport default Component.exports\n","import LoginForm from '../login_form/login_form.vue'\nimport MFARecoveryForm from '../mfa_form/recovery_form.vue'\nimport MFATOTPForm from '../mfa_form/totp_form.vue'\nimport { mapGetters } from 'vuex'\n\nconst AuthForm = {\n name: 'AuthForm',\n render (createElement) {\n return createElement('component', { is: this.authForm })\n },\n computed: {\n authForm () {\n if (this.requiredTOTP) { return 'MFATOTPForm' }\n if (this.requiredRecovery) { return 'MFARecoveryForm' }\n return 'LoginForm'\n },\n ...mapGetters('authFlow', ['requiredTOTP', 'requiredRecovery'])\n },\n components: {\n MFARecoveryForm,\n MFATOTPForm,\n LoginForm\n }\n}\n\nexport default AuthForm\n","const verifyOTPCode = ({ app, instance, mfaToken, code }) => {\n const url = `${instance}/oauth/mfa/challenge`\n const form = new window.FormData()\n\n form.append('client_id', app.client_id)\n form.append('client_secret', app.client_secret)\n form.append('mfa_token', mfaToken)\n form.append('code', code)\n form.append('challenge_type', 'totp')\n\n return window.fetch(url, {\n method: 'POST',\n body: form\n }).then((data) => data.json())\n}\n\nconst verifyRecoveryCode = ({ app, instance, mfaToken, code }) => {\n const url = `${instance}/oauth/mfa/challenge`\n const form = new window.FormData()\n\n form.append('client_id', app.client_id)\n form.append('client_secret', app.client_secret)\n form.append('mfa_token', mfaToken)\n form.append('code', code)\n form.append('challenge_type', 'recovery')\n\n return window.fetch(url, {\n method: 'POST',\n body: form\n }).then((data) => data.json())\n}\n\nconst mfa = {\n verifyOTPCode,\n verifyRecoveryCode\n}\n\nexport default mfa\n","function injectStyle (context) {\n require(\"!!vue-style-loader!css-loader?minimize!../../../node_modules/vue-loader/lib/style-compiler/index?{\\\"optionsId\\\":\\\"0\\\",\\\"vue\\\":true,\\\"scoped\\\":false,\\\"sourceMap\\\":false}!sass-loader!../../../node_modules/vue-loader/lib/selector?type=styles&index=0!./chat_panel.vue\")\n}\n/* script */\nexport * from \"!!babel-loader!./chat_panel.js\"\nimport __vue_script__ from \"!!babel-loader!./chat_panel.js\"/* template */\nimport {render as __vue_render__, staticRenderFns as __vue_static_render_fns__} from \"!!../../../node_modules/vue-loader/lib/template-compiler/index?{\\\"id\\\":\\\"data-v-7ea51572\\\",\\\"hasScoped\\\":false,\\\"optionsId\\\":\\\"0\\\",\\\"buble\\\":{\\\"transforms\\\":{}}}!../../../node_modules/vue-loader/lib/selector?type=template&index=0!./chat_panel.vue\"\n/* template functional */\nvar __vue_template_functional__ = false\n/* styles */\nvar __vue_styles__ = injectStyle\n/* scopeId */\nvar __vue_scopeId__ = null\n/* moduleIdentifier (server only) */\nvar __vue_module_identifier__ = null\nimport normalizeComponent from \"!../../../node_modules/vue-loader/lib/runtime/component-normalizer\"\nvar Component = normalizeComponent(\n __vue_script__,\n __vue_render__,\n __vue_static_render_fns__,\n __vue_template_functional__,\n __vue_styles__,\n __vue_scopeId__,\n __vue_module_identifier__\n)\n\nexport default Component.exports\n","/* script */\nexport * from \"!!babel-loader!./instance_specific_panel.js\"\nimport __vue_script__ from \"!!babel-loader!./instance_specific_panel.js\"/* template */\nimport {render as __vue_render__, staticRenderFns as __vue_static_render_fns__} from \"!!../../../node_modules/vue-loader/lib/template-compiler/index?{\\\"id\\\":\\\"data-v-5b01187b\\\",\\\"hasScoped\\\":false,\\\"optionsId\\\":\\\"0\\\",\\\"buble\\\":{\\\"transforms\\\":{}}}!../../../node_modules/vue-loader/lib/selector?type=template&index=0!./instance_specific_panel.vue\"\n/* template functional */\nvar __vue_template_functional__ = false\n/* styles */\nvar __vue_styles__ = null\n/* scopeId */\nvar __vue_scopeId__ = null\n/* moduleIdentifier (server only) */\nvar __vue_module_identifier__ = null\nimport normalizeComponent from \"!../../../node_modules/vue-loader/lib/runtime/component-normalizer\"\nvar Component = normalizeComponent(\n __vue_script__,\n __vue_render__,\n __vue_static_render_fns__,\n __vue_template_functional__,\n __vue_styles__,\n __vue_scopeId__,\n __vue_module_identifier__\n)\n\nexport default Component.exports\n","function injectStyle (context) {\n require(\"!!vue-style-loader!css-loader?minimize!../../../node_modules/vue-loader/lib/style-compiler/index?{\\\"optionsId\\\":\\\"0\\\",\\\"vue\\\":true,\\\"scoped\\\":false,\\\"sourceMap\\\":false}!sass-loader!../../../node_modules/vue-loader/lib/selector?type=styles&index=0!./features_panel.vue\")\n}\n/* script */\nexport * from \"!!babel-loader!./features_panel.js\"\nimport __vue_script__ from \"!!babel-loader!./features_panel.js\"/* template */\nimport {render as __vue_render__, staticRenderFns as __vue_static_render_fns__} from \"!!../../../node_modules/vue-loader/lib/template-compiler/index?{\\\"id\\\":\\\"data-v-3443e05c\\\",\\\"hasScoped\\\":false,\\\"optionsId\\\":\\\"0\\\",\\\"buble\\\":{\\\"transforms\\\":{}}}!../../../node_modules/vue-loader/lib/selector?type=template&index=0!./features_panel.vue\"\n/* template functional */\nvar __vue_template_functional__ = false\n/* styles */\nvar __vue_styles__ = injectStyle\n/* scopeId */\nvar __vue_scopeId__ = null\n/* moduleIdentifier (server only) */\nvar __vue_module_identifier__ = null\nimport normalizeComponent from \"!../../../node_modules/vue-loader/lib/runtime/component-normalizer\"\nvar Component = normalizeComponent(\n __vue_script__,\n __vue_render__,\n __vue_static_render_fns__,\n __vue_template_functional__,\n __vue_styles__,\n __vue_scopeId__,\n __vue_module_identifier__\n)\n\nexport default Component.exports\n","function injectStyle (context) {\n require(\"!!vue-style-loader!css-loader?minimize!../../../node_modules/vue-loader/lib/style-compiler/index?{\\\"optionsId\\\":\\\"0\\\",\\\"vue\\\":true,\\\"scoped\\\":false,\\\"sourceMap\\\":false}!sass-loader!../../../node_modules/vue-loader/lib/selector?type=styles&index=0!./side_drawer.vue\")\n}\n/* script */\nexport * from \"!!babel-loader!./side_drawer.js\"\nimport __vue_script__ from \"!!babel-loader!./side_drawer.js\"/* template */\nimport {render as __vue_render__, staticRenderFns as __vue_static_render_fns__} from \"!!../../../node_modules/vue-loader/lib/template-compiler/index?{\\\"id\\\":\\\"data-v-5c94965a\\\",\\\"hasScoped\\\":false,\\\"optionsId\\\":\\\"0\\\",\\\"buble\\\":{\\\"transforms\\\":{}}}!../../../node_modules/vue-loader/lib/selector?type=template&index=0!./side_drawer.vue\"\n/* template functional */\nvar __vue_template_functional__ = false\n/* styles */\nvar __vue_styles__ = injectStyle\n/* scopeId */\nvar __vue_scopeId__ = null\n/* moduleIdentifier (server only) */\nvar __vue_module_identifier__ = null\nimport normalizeComponent from \"!../../../node_modules/vue-loader/lib/runtime/component-normalizer\"\nvar Component = normalizeComponent(\n __vue_script__,\n __vue_render__,\n __vue_static_render_fns__,\n __vue_template_functional__,\n __vue_styles__,\n __vue_scopeId__,\n __vue_module_identifier__\n)\n\nexport default Component.exports\n","\nexport const windowWidth = () =>\n window.innerWidth ||\n document.documentElement.clientWidth ||\n document.body.clientWidth\n","import Vue from 'vue'\nimport VueRouter from 'vue-router'\nimport Vuex from 'vuex'\n\nimport interfaceModule from './modules/interface.js'\nimport instanceModule from './modules/instance.js'\nimport statusesModule from './modules/statuses.js'\nimport usersModule from './modules/users.js'\nimport apiModule from './modules/api.js'\nimport configModule from './modules/config.js'\nimport chatModule from './modules/chat.js'\nimport oauthModule from './modules/oauth.js'\nimport authFlowModule from './modules/auth_flow.js'\nimport mediaViewerModule from './modules/media_viewer.js'\nimport oauthTokensModule from './modules/oauth_tokens.js'\nimport reportsModule from './modules/reports.js'\nimport pollsModule from './modules/polls.js'\nimport postStatusModule from './modules/postStatus.js'\n\nimport VueI18n from 'vue-i18n'\n\nimport createPersistedState from './lib/persisted_state.js'\nimport pushNotifications from './lib/push_notifications_plugin.js'\n\nimport messages from './i18n/messages.js'\n\nimport VueChatScroll from 'vue-chat-scroll'\nimport VueClickOutside from 'v-click-outside'\nimport PortalVue from 'portal-vue'\nimport VBodyScrollLock from './directives/body_scroll_lock'\nimport VTooltip from 'v-tooltip'\n\nimport afterStoreSetup from './boot/after_store.js'\n\nconst currentLocale = (window.navigator.language || 'en').split('-')[0]\n\nVue.use(Vuex)\nVue.use(VueRouter)\nVue.use(VueI18n)\nVue.use(VueChatScroll)\nVue.use(VueClickOutside)\nVue.use(PortalVue)\nVue.use(VBodyScrollLock)\nVue.use(VTooltip, {\n popover: {\n defaultTrigger: 'hover click',\n defaultContainer: false,\n defaultOffset: 5\n }\n})\n\nconst i18n = new VueI18n({\n // By default, use the browser locale, we will update it if neccessary\n locale: currentLocale,\n fallbackLocale: 'en',\n messages\n})\n\nconst persistedStateOptions = {\n paths: [\n 'config',\n 'users.lastLoginName',\n 'oauth'\n ]\n};\n\n(async () => {\n const persistedState = await createPersistedState(persistedStateOptions)\n const store = new Vuex.Store({\n modules: {\n i18n: {\n getters: {\n i18n: () => i18n\n }\n },\n interface: interfaceModule,\n instance: instanceModule,\n statuses: statusesModule,\n users: usersModule,\n api: apiModule,\n config: configModule,\n chat: chatModule,\n oauth: oauthModule,\n authFlow: authFlowModule,\n mediaViewer: mediaViewerModule,\n oauthTokens: oauthTokensModule,\n reports: reportsModule,\n polls: pollsModule,\n postStatus: postStatusModule\n },\n plugins: [persistedState, pushNotifications],\n strict: false // Socket modifies itself, let's ignore this for now.\n // strict: process.env.NODE_ENV !== 'production'\n })\n\n afterStoreSetup({ store, i18n })\n})()\n\n// These are inlined by webpack's DefinePlugin\n/* eslint-disable */\nwindow.___pleromafe_mode = process.env\nwindow.___pleromafe_commit_hash = COMMIT_HASH\nwindow.___pleromafe_dev_overrides = DEV_OVERRIDES\n","import { set, delete as del } from 'vue'\n\nconst defaultState = {\n settings: {\n currentSaveStateNotice: null,\n noticeClearTimeout: null,\n notificationPermission: null\n },\n browserSupport: {\n cssFilter: window.CSS && window.CSS.supports && (\n window.CSS.supports('filter', 'drop-shadow(0 0)') ||\n window.CSS.supports('-webkit-filter', 'drop-shadow(0 0)')\n )\n },\n mobileLayout: false\n}\n\nconst interfaceMod = {\n state: defaultState,\n mutations: {\n settingsSaved (state, { success, error }) {\n if (success) {\n if (state.noticeClearTimeout) {\n clearTimeout(state.noticeClearTimeout)\n }\n set(state.settings, 'currentSaveStateNotice', { error: false, data: success })\n set(state.settings, 'noticeClearTimeout',\n setTimeout(() => del(state.settings, 'currentSaveStateNotice'), 2000))\n } else {\n set(state.settings, 'currentSaveStateNotice', { error: true, errorData: error })\n }\n },\n setNotificationPermission (state, permission) {\n state.notificationPermission = permission\n },\n setMobileLayout (state, value) {\n state.mobileLayout = value\n }\n },\n actions: {\n setPageTitle ({ rootState }, option = '') {\n document.title = `${option} ${rootState.instance.name}`\n },\n settingsSaved ({ commit, dispatch }, { success, error }) {\n commit('settingsSaved', { success, error })\n },\n setNotificationPermission ({ commit }, permission) {\n commit('setNotificationPermission', permission)\n },\n setMobileLayout ({ commit }, value) {\n commit('setMobileLayout', value)\n }\n }\n}\n\nexport default interfaceMod\n","import { set } from 'vue'\nimport { setPreset } from '../services/style_setter/style_setter.js'\nimport { instanceDefaultProperties } from './config.js'\n\nconst defaultState = {\n // Stuff from static/config.json and apiConfig\n name: 'Pleroma FE',\n registrationOpen: true,\n safeDM: true,\n textlimit: 5000,\n server: 'http://localhost:4040/',\n theme: 'pleroma-dark',\n background: '/static/aurora_borealis.jpg',\n logo: '/static/logo.png',\n logoMask: true,\n logoMargin: '.2em',\n redirectRootNoLogin: '/main/all',\n redirectRootLogin: '/main/friends',\n showInstanceSpecificPanel: false,\n alwaysShowSubjectInput: true,\n hideMutedPosts: false,\n collapseMessageWithSubject: false,\n hidePostStats: false,\n hideUserStats: false,\n hideFilteredStatuses: false,\n disableChat: false,\n scopeCopy: true,\n subjectLineBehavior: 'email',\n postContentType: 'text/plain',\n nsfwCensorImage: undefined,\n vapidPublicKey: undefined,\n noAttachmentLinks: false,\n showFeaturesPanel: true,\n minimalScopesMode: false,\n\n // Nasty stuff\n pleromaBackend: true,\n emoji: [],\n emojiFetched: false,\n customEmoji: [],\n customEmojiFetched: false,\n restrictedNicknames: [],\n postFormats: [],\n\n // Feature-set, apparently, not everything here is reported...\n mediaProxyAvailable: false,\n chatAvailable: false,\n gopherAvailable: false,\n suggestionsEnabled: false,\n suggestionsWeb: '',\n\n // Html stuff\n instanceSpecificPanelContent: '',\n tos: '',\n\n // Version Information\n backendVersion: '',\n frontendVersion: '',\n\n pollsAvailable: false,\n pollLimits: {\n max_options: 4,\n max_option_chars: 255,\n min_expiration: 60,\n max_expiration: 60 * 60 * 24\n }\n}\n\nconst instance = {\n state: defaultState,\n mutations: {\n setInstanceOption (state, { name, value }) {\n if (typeof value !== 'undefined') {\n set(state, name, value)\n }\n }\n },\n getters: {\n instanceDefaultConfig (state) {\n return instanceDefaultProperties\n .map(key => [key, state[key]])\n .reduce((acc, [key, value]) => ({ ...acc, [key]: value }), {})\n }\n },\n actions: {\n setInstanceOption ({ commit, dispatch }, { name, value }) {\n commit('setInstanceOption', { name, value })\n switch (name) {\n case 'name':\n dispatch('setPageTitle')\n break\n case 'chatAvailable':\n if (value) {\n dispatch('initializeSocket')\n }\n break\n }\n },\n async getStaticEmoji ({ commit }) {\n try {\n const res = await window.fetch('/static/emoji.json')\n if (res.ok) {\n const values = await res.json()\n const emoji = Object.keys(values).map((key) => {\n return {\n displayText: key,\n imageUrl: false,\n replacement: values[key]\n }\n }).sort((a, b) => a.displayText - b.displayText)\n commit('setInstanceOption', { name: 'emoji', value: emoji })\n } else {\n throw (res)\n }\n } catch (e) {\n console.warn(\"Can't load static emoji\")\n console.warn(e)\n }\n },\n\n async getCustomEmoji ({ commit, state }) {\n try {\n const res = await window.fetch('/api/pleroma/emoji.json')\n if (res.ok) {\n const result = await res.json()\n const values = Array.isArray(result) ? Object.assign({}, ...result) : result\n const emoji = Object.entries(values).map(([key, value]) => {\n const imageUrl = value.image_url\n return {\n displayText: key,\n imageUrl: imageUrl ? state.server + imageUrl : value,\n tags: imageUrl ? value.tags.sort((a, b) => a > b ? 1 : 0) : ['utf'],\n replacement: `:${key}: `\n }\n // Technically could use tags but those are kinda useless right now,\n // should have been \"pack\" field, that would be more useful\n }).sort((a, b) => a.displayText.toLowerCase() > b.displayText.toLowerCase() ? 1 : 0)\n commit('setInstanceOption', { name: 'customEmoji', value: emoji })\n } else {\n throw (res)\n }\n } catch (e) {\n console.warn(\"Can't load custom emojis\")\n console.warn(e)\n }\n },\n\n setTheme ({ commit }, themeName) {\n commit('setInstanceOption', { name: 'theme', value: themeName })\n return setPreset(themeName, commit)\n },\n fetchEmoji ({ dispatch, state }) {\n if (!state.customEmojiFetched) {\n state.customEmojiFetched = true\n dispatch('getCustomEmoji')\n }\n if (!state.emojiFetched) {\n state.emojiFetched = true\n dispatch('getStaticEmoji')\n }\n }\n }\n}\n\nexport default instance\n","import { remove, slice, each, findIndex, find, maxBy, minBy, merge, first, last, isArray, omitBy } from 'lodash'\nimport { set } from 'vue'\nimport apiService from '../services/api/api.service.js'\n// import parse from '../services/status_parser/status_parser.js'\n\nconst emptyTl = (userId = 0) => ({\n statuses: [],\n statusesObject: {},\n faves: [],\n visibleStatuses: [],\n visibleStatusesObject: {},\n newStatusCount: 0,\n maxId: 0,\n minId: 0,\n minVisibleId: 0,\n loading: false,\n followers: [],\n friends: [],\n userId,\n flushMarker: 0\n})\n\nconst emptyNotifications = () => ({\n desktopNotificationSilence: true,\n maxId: 0,\n minId: Number.POSITIVE_INFINITY,\n data: [],\n idStore: {},\n loading: false,\n error: false\n})\n\nexport const defaultState = () => ({\n allStatuses: [],\n allStatusesObject: {},\n conversationsObject: {},\n maxId: 0,\n notifications: emptyNotifications(),\n favorites: new Set(),\n error: false,\n timelines: {\n mentions: emptyTl(),\n public: emptyTl(),\n user: emptyTl(),\n favorites: emptyTl(),\n media: emptyTl(),\n publicAndExternal: emptyTl(),\n friends: emptyTl(),\n tag: emptyTl(),\n dms: emptyTl()\n }\n})\n\nexport const prepareStatus = (status) => {\n // Set deleted flag\n status.deleted = false\n\n // To make the array reactive\n status.attachments = status.attachments || []\n\n return status\n}\n\nconst visibleNotificationTypes = (rootState) => {\n return [\n rootState.config.notificationVisibility.likes && 'like',\n rootState.config.notificationVisibility.mentions && 'mention',\n rootState.config.notificationVisibility.repeats && 'repeat',\n rootState.config.notificationVisibility.follows && 'follow'\n ].filter(_ => _)\n}\n\nconst mergeOrAdd = (arr, obj, item) => {\n const oldItem = obj[item.id]\n\n if (oldItem) {\n // We already have this, so only merge the new info.\n // We ignore null values to avoid overwriting existing properties with missing data\n // we also skip 'user' because that is handled by users module\n merge(oldItem, omitBy(item, (v, k) => v === null || k === 'user'))\n // Reactivity fix.\n oldItem.attachments.splice(oldItem.attachments.length)\n return { item: oldItem, new: false }\n } else {\n // This is a new item, prepare it\n prepareStatus(item)\n arr.push(item)\n set(obj, item.id, item)\n return { item, new: true }\n }\n}\n\nconst sortById = (a, b) => {\n const seqA = Number(a.id)\n const seqB = Number(b.id)\n const isSeqA = !Number.isNaN(seqA)\n const isSeqB = !Number.isNaN(seqB)\n if (isSeqA && isSeqB) {\n return seqA > seqB ? -1 : 1\n } else if (isSeqA && !isSeqB) {\n return 1\n } else if (!isSeqA && isSeqB) {\n return -1\n } else {\n return a.id > b.id ? -1 : 1\n }\n}\n\nconst sortTimeline = (timeline) => {\n timeline.visibleStatuses = timeline.visibleStatuses.sort(sortById)\n timeline.statuses = timeline.statuses.sort(sortById)\n timeline.minVisibleId = (last(timeline.visibleStatuses) || {}).id\n return timeline\n}\n\n// Add status to the global storages (arrays and objects maintaining statuses) except timelines\nconst addStatusToGlobalStorage = (state, data) => {\n const result = mergeOrAdd(state.allStatuses, state.allStatusesObject, data)\n if (result.new) {\n // Add to conversation\n const status = result.item\n const conversationsObject = state.conversationsObject\n const conversationId = status.statusnet_conversation_id\n if (conversationsObject[conversationId]) {\n conversationsObject[conversationId].push(status)\n } else {\n set(conversationsObject, conversationId, [status])\n }\n }\n return result\n}\n\n// Remove status from the global storages (arrays and objects maintaining statuses) except timelines\nconst removeStatusFromGlobalStorage = (state, status) => {\n remove(state.allStatuses, { id: status.id })\n\n // TODO: Need to remove from allStatusesObject?\n\n // Remove possible notification\n remove(state.notifications.data, ({ action: { id } }) => id === status.id)\n\n // Remove from conversation\n const conversationId = status.statusnet_conversation_id\n if (state.conversationsObject[conversationId]) {\n remove(state.conversationsObject[conversationId], { id: status.id })\n }\n}\n\nconst addNewStatuses = (state, { statuses, showImmediately = false, timeline, user = {},\n noIdUpdate = false, userId }) => {\n // Sanity check\n if (!isArray(statuses)) {\n return false\n }\n\n const allStatuses = state.allStatuses\n const timelineObject = state.timelines[timeline]\n\n const maxNew = statuses.length > 0 ? maxBy(statuses, 'id').id : 0\n const minNew = statuses.length > 0 ? minBy(statuses, 'id').id : 0\n const newer = timeline && (maxNew > timelineObject.maxId || timelineObject.maxId === 0) && statuses.length > 0\n const older = timeline && (minNew < timelineObject.minId || timelineObject.minId === 0) && statuses.length > 0\n\n if (!noIdUpdate && newer) {\n timelineObject.maxId = maxNew\n }\n if (!noIdUpdate && older) {\n timelineObject.minId = minNew\n }\n\n // This makes sure that user timeline won't get data meant for other\n // user. I.e. opening different user profiles makes request which could\n // return data late after user already viewing different user profile\n if ((timeline === 'user' || timeline === 'media') && timelineObject.userId !== userId) {\n return\n }\n\n const addStatus = (data, showImmediately, addToTimeline = true) => {\n const result = addStatusToGlobalStorage(state, data)\n const status = result.item\n\n if (result.new) {\n // We are mentioned in a post\n if (status.type === 'status' && find(status.attentions, { id: user.id })) {\n const mentions = state.timelines.mentions\n\n // Add the mention to the mentions timeline\n if (timelineObject !== mentions) {\n mergeOrAdd(mentions.statuses, mentions.statusesObject, status)\n mentions.newStatusCount += 1\n\n sortTimeline(mentions)\n }\n }\n if (status.visibility === 'direct') {\n const dms = state.timelines.dms\n\n mergeOrAdd(dms.statuses, dms.statusesObject, status)\n dms.newStatusCount += 1\n\n sortTimeline(dms)\n }\n }\n\n // Decide if we should treat the status as new for this timeline.\n let resultForCurrentTimeline\n // Some statuses should only be added to the global status repository.\n if (timeline && addToTimeline) {\n resultForCurrentTimeline = mergeOrAdd(timelineObject.statuses, timelineObject.statusesObject, status)\n }\n\n if (timeline && showImmediately) {\n // Add it directly to the visibleStatuses, don't change\n // newStatusCount\n mergeOrAdd(timelineObject.visibleStatuses, timelineObject.visibleStatusesObject, status)\n } else if (timeline && addToTimeline && resultForCurrentTimeline.new) {\n // Just change newStatuscount\n timelineObject.newStatusCount += 1\n }\n\n return status\n }\n\n const favoriteStatus = (favorite, counter) => {\n const status = find(allStatuses, { id: favorite.in_reply_to_status_id })\n if (status) {\n // This is our favorite, so the relevant bit.\n if (favorite.user.id === user.id) {\n status.favorited = true\n } else {\n status.fave_num += 1\n }\n }\n return status\n }\n\n const processors = {\n 'status': (status) => {\n addStatus(status, showImmediately)\n },\n 'retweet': (status) => {\n // RetweetedStatuses are never shown immediately\n const retweetedStatus = addStatus(status.retweeted_status, false, false)\n\n let retweet\n // If the retweeted status is already there, don't add the retweet\n // to the timeline.\n if (timeline && find(timelineObject.statuses, (s) => {\n if (s.retweeted_status) {\n return s.id === retweetedStatus.id || s.retweeted_status.id === retweetedStatus.id\n } else {\n return s.id === retweetedStatus.id\n }\n })) {\n // Already have it visible (either as the original or another RT), don't add to timeline, don't show.\n retweet = addStatus(status, false, false)\n } else {\n retweet = addStatus(status, showImmediately)\n }\n\n retweet.retweeted_status = retweetedStatus\n },\n 'favorite': (favorite) => {\n // Only update if this is a new favorite.\n // Ignore our own favorites because we get info about likes as response to like request\n if (!state.favorites.has(favorite.id)) {\n state.favorites.add(favorite.id)\n favoriteStatus(favorite)\n }\n },\n 'deletion': (deletion) => {\n const uri = deletion.uri\n const status = find(allStatuses, { uri })\n if (!status) {\n return\n }\n\n removeStatusFromGlobalStorage(state, status)\n\n if (timeline) {\n remove(timelineObject.statuses, { uri })\n remove(timelineObject.visibleStatuses, { uri })\n }\n },\n 'follow': (follow) => {\n // NOOP, it is known status but we don't do anything about it for now\n },\n 'default': (unknown) => {\n console.log('unknown status type')\n console.log(unknown)\n }\n }\n\n each(statuses, (status) => {\n const type = status.type\n const processor = processors[type] || processors['default']\n processor(status)\n })\n\n // Keep the visible statuses sorted\n if (timeline) {\n sortTimeline(timelineObject)\n }\n}\n\nconst addNewNotifications = (state, { dispatch, notifications, older, visibleNotificationTypes, rootGetters }) => {\n each(notifications, (notification) => {\n if (notification.type !== 'follow') {\n notification.action = addStatusToGlobalStorage(state, notification.action).item\n notification.status = notification.status && addStatusToGlobalStorage(state, notification.status).item\n }\n\n // Only add a new notification if we don't have one for the same action\n if (!state.notifications.idStore.hasOwnProperty(notification.id)) {\n state.notifications.maxId = notification.id > state.notifications.maxId\n ? notification.id\n : state.notifications.maxId\n state.notifications.minId = notification.id < state.notifications.minId\n ? notification.id\n : state.notifications.minId\n\n state.notifications.data.push(notification)\n state.notifications.idStore[notification.id] = notification\n\n if ('Notification' in window && window.Notification.permission === 'granted') {\n const notifObj = {}\n const status = notification.status\n const title = notification.from_profile.name\n notifObj.icon = notification.from_profile.profile_image_url\n let i18nString\n switch (notification.type) {\n case 'like':\n i18nString = 'favorited_you'\n break\n case 'repeat':\n i18nString = 'repeated_you'\n break\n case 'follow':\n i18nString = 'followed_you'\n break\n }\n\n if (i18nString) {\n notifObj.body = rootGetters.i18n.t('notifications.' + i18nString)\n } else {\n notifObj.body = notification.status.text\n }\n\n // Shows first attached non-nsfw image, if any. Should add configuration for this somehow...\n if (status && status.attachments && status.attachments.length > 0 && !status.nsfw &&\n status.attachments[0].mimetype.startsWith('image/')) {\n notifObj.image = status.attachments[0].url\n }\n\n if (!notification.seen && !state.notifications.desktopNotificationSilence && visibleNotificationTypes.includes(notification.type)) {\n let notification = new window.Notification(title, notifObj)\n // Chrome is known for not closing notifications automatically\n // according to MDN, anyway.\n setTimeout(notification.close.bind(notification), 5000)\n }\n }\n } else if (notification.seen) {\n state.notifications.idStore[notification.id].seen = true\n }\n })\n}\n\nconst removeStatus = (state, { timeline, userId }) => {\n const timelineObject = state.timelines[timeline]\n if (userId) {\n remove(timelineObject.statuses, { user: { id: userId } })\n remove(timelineObject.visibleStatuses, { user: { id: userId } })\n timelineObject.minVisibleId = timelineObject.visibleStatuses.length > 0 ? last(timelineObject.visibleStatuses).id : 0\n timelineObject.maxId = timelineObject.statuses.length > 0 ? first(timelineObject.statuses).id : 0\n }\n}\n\nexport const mutations = {\n addNewStatuses,\n addNewNotifications,\n removeStatus,\n showNewStatuses (state, { timeline }) {\n const oldTimeline = (state.timelines[timeline])\n\n oldTimeline.newStatusCount = 0\n oldTimeline.visibleStatuses = slice(oldTimeline.statuses, 0, 50)\n oldTimeline.minVisibleId = last(oldTimeline.visibleStatuses).id\n oldTimeline.minId = oldTimeline.minVisibleId\n oldTimeline.visibleStatusesObject = {}\n each(oldTimeline.visibleStatuses, (status) => { oldTimeline.visibleStatusesObject[status.id] = status })\n },\n resetStatuses (state) {\n const emptyState = defaultState()\n Object.entries(emptyState).forEach(([key, value]) => {\n state[key] = value\n })\n },\n clearTimeline (state, { timeline, excludeUserId = false }) {\n const userId = excludeUserId ? state.timelines[timeline].userId : undefined\n state.timelines[timeline] = emptyTl(userId)\n },\n clearNotifications (state) {\n state.notifications = emptyNotifications()\n },\n setFavorited (state, { status, value }) {\n const newStatus = state.allStatusesObject[status.id]\n\n if (newStatus.favorited !== value) {\n if (value) {\n newStatus.fave_num++\n } else {\n newStatus.fave_num--\n }\n }\n\n newStatus.favorited = value\n },\n setFavoritedConfirm (state, { status, user }) {\n const newStatus = state.allStatusesObject[status.id]\n newStatus.favorited = status.favorited\n newStatus.fave_num = status.fave_num\n const index = findIndex(newStatus.favoritedBy, { id: user.id })\n if (index !== -1 && !newStatus.favorited) {\n newStatus.favoritedBy.splice(index, 1)\n } else if (index === -1 && newStatus.favorited) {\n newStatus.favoritedBy.push(user)\n }\n },\n setMutedStatus (state, status) {\n const newStatus = state.allStatusesObject[status.id]\n newStatus.thread_muted = status.thread_muted\n\n if (newStatus.thread_muted !== undefined) {\n state.conversationsObject[newStatus.statusnet_conversation_id].forEach(status => { status.thread_muted = newStatus.thread_muted })\n }\n },\n setRetweeted (state, { status, value }) {\n const newStatus = state.allStatusesObject[status.id]\n\n if (newStatus.repeated !== value) {\n if (value) {\n newStatus.repeat_num++\n } else {\n newStatus.repeat_num--\n }\n }\n\n newStatus.repeated = value\n },\n setRetweetedConfirm (state, { status, user }) {\n const newStatus = state.allStatusesObject[status.id]\n newStatus.repeated = status.repeated\n newStatus.repeat_num = status.repeat_num\n const index = findIndex(newStatus.rebloggedBy, { id: user.id })\n if (index !== -1 && !newStatus.repeated) {\n newStatus.rebloggedBy.splice(index, 1)\n } else if (index === -1 && newStatus.repeated) {\n newStatus.rebloggedBy.push(user)\n }\n },\n setDeleted (state, { status }) {\n const newStatus = state.allStatusesObject[status.id]\n newStatus.deleted = true\n },\n setManyDeleted (state, condition) {\n Object.values(state.allStatusesObject).forEach(status => {\n if (condition(status)) {\n status.deleted = true\n }\n })\n },\n setLoading (state, { timeline, value }) {\n state.timelines[timeline].loading = value\n },\n setNsfw (state, { id, nsfw }) {\n const newStatus = state.allStatusesObject[id]\n newStatus.nsfw = nsfw\n },\n setError (state, { value }) {\n state.error = value\n },\n setNotificationsLoading (state, { value }) {\n state.notifications.loading = value\n },\n setNotificationsError (state, { value }) {\n state.notifications.error = value\n },\n setNotificationsSilence (state, { value }) {\n state.notifications.desktopNotificationSilence = value\n },\n markNotificationsAsSeen (state) {\n each(state.notifications.data, (notification) => {\n notification.seen = true\n })\n },\n queueFlush (state, { timeline, id }) {\n state.timelines[timeline].flushMarker = id\n },\n addRepeats (state, { id, rebloggedByUsers, currentUser }) {\n const newStatus = state.allStatusesObject[id]\n newStatus.rebloggedBy = rebloggedByUsers.filter(_ => _)\n // repeats stats can be incorrect based on polling condition, let's update them using the most recent data\n newStatus.repeat_num = newStatus.rebloggedBy.length\n newStatus.repeated = !!newStatus.rebloggedBy.find(({ id }) => currentUser.id === id)\n },\n addFavs (state, { id, favoritedByUsers, currentUser }) {\n const newStatus = state.allStatusesObject[id]\n newStatus.favoritedBy = favoritedByUsers.filter(_ => _)\n // favorites stats can be incorrect based on polling condition, let's update them using the most recent data\n newStatus.fave_num = newStatus.favoritedBy.length\n newStatus.favorited = !!newStatus.favoritedBy.find(({ id }) => currentUser.id === id)\n },\n updateStatusWithPoll (state, { id, poll }) {\n const status = state.allStatusesObject[id]\n status.poll = poll\n }\n}\n\nconst statuses = {\n state: defaultState(),\n actions: {\n addNewStatuses ({ rootState, commit }, { statuses, showImmediately = false, timeline = false, noIdUpdate = false, userId }) {\n commit('addNewStatuses', { statuses, showImmediately, timeline, noIdUpdate, user: rootState.users.currentUser, userId })\n },\n addNewNotifications ({ rootState, commit, dispatch, rootGetters }, { notifications, older }) {\n commit('addNewNotifications', { visibleNotificationTypes: visibleNotificationTypes(rootState), dispatch, notifications, older, rootGetters })\n },\n setError ({ rootState, commit }, { value }) {\n commit('setError', { value })\n },\n setNotificationsLoading ({ rootState, commit }, { value }) {\n commit('setNotificationsLoading', { value })\n },\n setNotificationsError ({ rootState, commit }, { value }) {\n commit('setNotificationsError', { value })\n },\n setNotificationsSilence ({ rootState, commit }, { value }) {\n commit('setNotificationsSilence', { value })\n },\n fetchStatus ({ rootState, dispatch }, id) {\n rootState.api.backendInteractor.fetchStatus({ id })\n .then((status) => dispatch('addNewStatuses', { statuses: [status] }))\n },\n deleteStatus ({ rootState, commit }, status) {\n commit('setDeleted', { status })\n apiService.deleteStatus({ id: status.id, credentials: rootState.users.currentUser.credentials })\n },\n markStatusesAsDeleted ({ commit }, condition) {\n commit('setManyDeleted', condition)\n },\n favorite ({ rootState, commit }, status) {\n // Optimistic favoriting...\n commit('setFavorited', { status, value: true })\n rootState.api.backendInteractor.favorite(status.id)\n .then(status => commit('setFavoritedConfirm', { status, user: rootState.users.currentUser }))\n },\n unfavorite ({ rootState, commit }, status) {\n // Optimistic unfavoriting...\n commit('setFavorited', { status, value: false })\n rootState.api.backendInteractor.unfavorite(status.id)\n .then(status => commit('setFavoritedConfirm', { status, user: rootState.users.currentUser }))\n },\n fetchPinnedStatuses ({ rootState, dispatch }, userId) {\n rootState.api.backendInteractor.fetchPinnedStatuses(userId)\n .then(statuses => dispatch('addNewStatuses', { statuses, timeline: 'user', userId, showImmediately: true, noIdUpdate: true }))\n },\n pinStatus ({ rootState, dispatch }, statusId) {\n return rootState.api.backendInteractor.pinOwnStatus(statusId)\n .then((status) => dispatch('addNewStatuses', { statuses: [status] }))\n },\n unpinStatus ({ rootState, dispatch }, statusId) {\n rootState.api.backendInteractor.unpinOwnStatus(statusId)\n .then((status) => dispatch('addNewStatuses', { statuses: [status] }))\n },\n muteConversation ({ rootState, commit }, statusId) {\n return rootState.api.backendInteractor.muteConversation(statusId)\n .then((status) => commit('setMutedStatus', status))\n },\n unmuteConversation ({ rootState, commit }, statusId) {\n return rootState.api.backendInteractor.unmuteConversation(statusId)\n .then((status) => commit('setMutedStatus', status))\n },\n retweet ({ rootState, commit }, status) {\n // Optimistic retweeting...\n commit('setRetweeted', { status, value: true })\n rootState.api.backendInteractor.retweet(status.id)\n .then(status => commit('setRetweetedConfirm', { status: status.retweeted_status, user: rootState.users.currentUser }))\n },\n unretweet ({ rootState, commit }, status) {\n // Optimistic unretweeting...\n commit('setRetweeted', { status, value: false })\n rootState.api.backendInteractor.unretweet(status.id)\n .then(status => commit('setRetweetedConfirm', { status, user: rootState.users.currentUser }))\n },\n queueFlush ({ rootState, commit }, { timeline, id }) {\n commit('queueFlush', { timeline, id })\n },\n markNotificationsAsSeen ({ rootState, commit }) {\n commit('markNotificationsAsSeen')\n apiService.markNotificationsAsSeen({\n id: rootState.statuses.notifications.maxId,\n credentials: rootState.users.currentUser.credentials\n })\n },\n fetchFavsAndRepeats ({ rootState, commit }, id) {\n Promise.all([\n rootState.api.backendInteractor.fetchFavoritedByUsers(id),\n rootState.api.backendInteractor.fetchRebloggedByUsers(id)\n ]).then(([favoritedByUsers, rebloggedByUsers]) => {\n commit('addFavs', { id, favoritedByUsers, currentUser: rootState.users.currentUser })\n commit('addRepeats', { id, rebloggedByUsers, currentUser: rootState.users.currentUser })\n })\n },\n fetchFavs ({ rootState, commit }, id) {\n rootState.api.backendInteractor.fetchFavoritedByUsers(id)\n .then(favoritedByUsers => commit('addFavs', { id, favoritedByUsers, currentUser: rootState.users.currentUser }))\n },\n fetchRepeats ({ rootState, commit }, id) {\n rootState.api.backendInteractor.fetchRebloggedByUsers(id)\n .then(rebloggedByUsers => commit('addRepeats', { id, rebloggedByUsers, currentUser: rootState.users.currentUser }))\n },\n search (store, { q, resolve, limit, offset, following }) {\n return store.rootState.api.backendInteractor.search2({ q, resolve, limit, offset, following })\n .then((data) => {\n store.commit('addNewUsers', data.accounts)\n store.commit('addNewStatuses', { statuses: data.statuses })\n return data\n })\n }\n },\n mutations\n}\n\nexport default statuses\n","const qvitterStatusType = (status) => {\n if (status.is_post_verb) {\n return 'status'\n }\n\n if (status.retweeted_status) {\n return 'retweet'\n }\n\n if ((typeof status.uri === 'string' && status.uri.match(/(fave|objectType=Favourite)/)) ||\n (typeof status.text === 'string' && status.text.match(/favorited/))) {\n return 'favorite'\n }\n\n if (status.text.match(/deleted notice {{tag/) || status.qvitter_delete_notice) {\n return 'deletion'\n }\n\n if (status.text.match(/started following/) || status.activity_type === 'follow') {\n return 'follow'\n }\n\n return 'unknown'\n}\n\nexport const parseUser = (data) => {\n const output = {}\n const masto = data.hasOwnProperty('acct')\n // case for users in \"mentions\" property for statuses in MastoAPI\n const mastoShort = masto && !data.hasOwnProperty('avatar')\n\n output.id = String(data.id)\n\n if (masto) {\n output.screen_name = data.acct\n output.statusnet_profile_url = data.url\n\n // There's nothing else to get\n if (mastoShort) {\n return output\n }\n\n output.name = data.display_name\n output.name_html = addEmojis(data.display_name, data.emojis)\n\n output.description = data.note\n output.description_html = addEmojis(data.note, data.emojis)\n\n // Utilize avatar_static for gif avatars?\n output.profile_image_url = data.avatar\n output.profile_image_url_original = data.avatar\n\n // Same, utilize header_static?\n output.cover_photo = data.header\n\n output.friends_count = data.following_count\n\n output.bot = data.bot\n\n if (data.pleroma) {\n const relationship = data.pleroma.relationship\n\n output.background_image = data.pleroma.background_image\n output.token = data.pleroma.chat_token\n\n if (relationship) {\n output.follows_you = relationship.followed_by\n output.requested = relationship.requested\n output.following = relationship.following\n output.statusnet_blocking = relationship.blocking\n output.muted = relationship.muting\n output.showing_reblogs = relationship.showing_reblogs\n output.subscribed = relationship.subscribing\n }\n\n output.hide_follows = data.pleroma.hide_follows\n output.hide_followers = data.pleroma.hide_followers\n output.hide_follows_count = data.pleroma.hide_follows_count\n output.hide_followers_count = data.pleroma.hide_followers_count\n\n output.rights = {\n moderator: data.pleroma.is_moderator,\n admin: data.pleroma.is_admin\n }\n // TODO: Clean up in UI? This is duplication from what BE does for qvitterapi\n if (output.rights.admin) {\n output.role = 'admin'\n } else if (output.rights.moderator) {\n output.role = 'moderator'\n } else {\n output.role = 'member'\n }\n }\n\n if (data.source) {\n output.description = data.source.note\n output.default_scope = data.source.privacy\n if (data.source.pleroma) {\n output.no_rich_text = data.source.pleroma.no_rich_text\n output.show_role = data.source.pleroma.show_role\n output.discoverable = data.source.pleroma.discoverable\n }\n }\n\n // TODO: handle is_local\n output.is_local = !output.screen_name.includes('@')\n } else {\n output.screen_name = data.screen_name\n\n output.name = data.name\n output.name_html = data.name_html\n\n output.description = data.description\n output.description_html = data.description_html\n\n output.profile_image_url = data.profile_image_url\n output.profile_image_url_original = data.profile_image_url_original\n\n output.cover_photo = data.cover_photo\n\n output.friends_count = data.friends_count\n\n // output.bot = ??? missing\n\n output.statusnet_profile_url = data.statusnet_profile_url\n\n output.statusnet_blocking = data.statusnet_blocking\n\n output.is_local = data.is_local\n output.role = data.role\n output.show_role = data.show_role\n\n output.follows_you = data.follows_you\n\n output.muted = data.muted\n\n if (data.rights) {\n output.rights = {\n moderator: data.rights.delete_others_notice,\n admin: data.rights.admin\n }\n }\n output.no_rich_text = data.no_rich_text\n output.default_scope = data.default_scope\n output.hide_follows = data.hide_follows\n output.hide_followers = data.hide_followers\n output.hide_follows_count = data.hide_follows_count\n output.hide_followers_count = data.hide_followers_count\n output.background_image = data.background_image\n // on mastoapi this info is contained in a \"relationship\"\n output.following = data.following\n // Websocket token\n output.token = data.token\n }\n\n output.created_at = new Date(data.created_at)\n output.locked = data.locked\n output.followers_count = data.followers_count\n output.statuses_count = data.statuses_count\n output.friendIds = []\n output.followerIds = []\n output.pinnedStatusIds = []\n\n if (data.pleroma) {\n output.follow_request_count = data.pleroma.follow_request_count\n\n output.tags = data.pleroma.tags\n output.deactivated = data.pleroma.deactivated\n\n output.notification_settings = data.pleroma.notification_settings\n }\n\n output.tags = output.tags || []\n output.rights = output.rights || {}\n output.notification_settings = output.notification_settings || {}\n\n return output\n}\n\nexport const parseAttachment = (data) => {\n const output = {}\n const masto = !data.hasOwnProperty('oembed')\n\n if (masto) {\n // Not exactly same...\n output.mimetype = data.pleroma ? data.pleroma.mime_type : data.type\n output.meta = data.meta // not present in BE yet\n output.id = data.id\n } else {\n output.mimetype = data.mimetype\n // output.meta = ??? missing\n }\n\n output.url = data.url\n output.description = data.description\n\n return output\n}\nexport const addEmojis = (string, emojis) => {\n const matchOperatorsRegex = /[|\\\\{}()[\\]^$+*?.-]/g\n return emojis.reduce((acc, emoji) => {\n const regexSafeShortCode = emoji.shortcode.replace(matchOperatorsRegex, '\\\\$&')\n return acc.replace(\n new RegExp(`:${regexSafeShortCode}:`, 'g'),\n `${emoji.shortcode}`\n )\n }, string)\n}\n\nexport const parseStatus = (data) => {\n const output = {}\n const masto = data.hasOwnProperty('account')\n\n if (masto) {\n output.favorited = data.favourited\n output.fave_num = data.favourites_count\n\n output.repeated = data.reblogged\n output.repeat_num = data.reblogs_count\n\n output.type = data.reblog ? 'retweet' : 'status'\n output.nsfw = data.sensitive\n\n output.statusnet_html = addEmojis(data.content, data.emojis)\n\n output.tags = data.tags\n\n if (data.pleroma) {\n const { pleroma } = data\n output.text = pleroma.content ? data.pleroma.content['text/plain'] : data.content\n output.summary = pleroma.spoiler_text ? data.pleroma.spoiler_text['text/plain'] : data.spoiler_text\n output.statusnet_conversation_id = data.pleroma.conversation_id\n output.is_local = pleroma.local\n output.in_reply_to_screen_name = data.pleroma.in_reply_to_account_acct\n output.thread_muted = pleroma.thread_muted\n } else {\n output.text = data.content\n output.summary = data.spoiler_text\n }\n\n output.in_reply_to_status_id = data.in_reply_to_id\n output.in_reply_to_user_id = data.in_reply_to_account_id\n output.replies_count = data.replies_count\n\n if (output.type === 'retweet') {\n output.retweeted_status = parseStatus(data.reblog)\n }\n\n output.summary_html = addEmojis(data.spoiler_text, data.emojis)\n output.external_url = data.url\n output.poll = data.poll\n output.pinned = data.pinned\n output.muted = data.muted\n } else {\n output.favorited = data.favorited\n output.fave_num = data.fave_num\n\n output.repeated = data.repeated\n output.repeat_num = data.repeat_num\n\n // catchall, temporary\n // Object.assign(output, data)\n\n output.type = qvitterStatusType(data)\n\n if (data.nsfw === undefined) {\n output.nsfw = isNsfw(data)\n if (data.retweeted_status) {\n output.nsfw = data.retweeted_status.nsfw\n }\n } else {\n output.nsfw = data.nsfw\n }\n\n output.statusnet_html = data.statusnet_html\n output.text = data.text\n\n output.in_reply_to_status_id = data.in_reply_to_status_id\n output.in_reply_to_user_id = data.in_reply_to_user_id\n output.in_reply_to_screen_name = data.in_reply_to_screen_name\n output.statusnet_conversation_id = data.statusnet_conversation_id\n\n if (output.type === 'retweet') {\n output.retweeted_status = parseStatus(data.retweeted_status)\n }\n\n output.summary = data.summary\n output.summary_html = data.summary_html\n output.external_url = data.external_url\n output.is_local = data.is_local\n }\n\n output.id = String(data.id)\n output.visibility = data.visibility\n output.card = data.card\n output.created_at = new Date(data.created_at)\n\n // Converting to string, the right way.\n output.in_reply_to_status_id = output.in_reply_to_status_id\n ? String(output.in_reply_to_status_id)\n : null\n output.in_reply_to_user_id = output.in_reply_to_user_id\n ? String(output.in_reply_to_user_id)\n : null\n\n output.user = parseUser(masto ? data.account : data.user)\n\n output.attentions = ((masto ? data.mentions : data.attentions) || []).map(parseUser)\n\n output.attachments = ((masto ? data.media_attachments : data.attachments) || [])\n .map(parseAttachment)\n\n const retweetedStatus = masto ? data.reblog : data.retweeted_status\n if (retweetedStatus) {\n output.retweeted_status = parseStatus(retweetedStatus)\n }\n\n output.favoritedBy = []\n output.rebloggedBy = []\n\n return output\n}\n\nexport const parseNotification = (data) => {\n const mastoDict = {\n 'favourite': 'like',\n 'reblog': 'repeat'\n }\n const masto = !data.hasOwnProperty('ntype')\n const output = {}\n\n if (masto) {\n output.type = mastoDict[data.type] || data.type\n output.seen = data.pleroma.is_seen\n output.status = output.type === 'follow'\n ? null\n : parseStatus(data.status)\n output.action = output.status // TODO: Refactor, this is unneeded\n output.from_profile = parseUser(data.account)\n } else {\n const parsedNotice = parseStatus(data.notice)\n output.type = data.ntype\n output.seen = Boolean(data.is_seen)\n output.status = output.type === 'like'\n ? parseStatus(data.notice.favorited_status)\n : parsedNotice\n output.action = parsedNotice\n output.from_profile = parseUser(data.from_profile)\n }\n\n output.created_at = new Date(data.created_at)\n output.id = parseInt(data.id)\n\n return output\n}\n\nconst isNsfw = (status) => {\n const nsfwRegex = /#nsfw/i\n return (status.tags || []).includes('nsfw') || !!(status.text || '').match(nsfwRegex)\n}\n","import { humanizeErrors } from '../../modules/errors'\n\nexport function StatusCodeError (statusCode, body, options, response) {\n this.name = 'StatusCodeError'\n this.statusCode = statusCode\n this.message = statusCode + ' - ' + (JSON && JSON.stringify ? JSON.stringify(body) : body)\n this.error = body // legacy attribute\n this.options = options\n this.response = response\n\n if (Error.captureStackTrace) { // required for non-V8 environments\n Error.captureStackTrace(this)\n }\n}\nStatusCodeError.prototype = Object.create(Error.prototype)\nStatusCodeError.prototype.constructor = StatusCodeError\n\nexport class RegistrationError extends Error {\n constructor (error) {\n super()\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this)\n }\n\n try {\n // the error is probably a JSON object with a single key, \"errors\", whose value is another JSON object containing the real errors\n if (typeof error === 'string') {\n error = JSON.parse(error)\n if (error.hasOwnProperty('error')) {\n error = JSON.parse(error.error)\n }\n }\n\n if (typeof error === 'object') {\n // replace ap_id with username\n if (error.ap_id) {\n error.username = error.ap_id\n delete error.ap_id\n }\n this.message = humanizeErrors(error)\n } else {\n this.message = error\n }\n } catch (e) {\n // can't parse it, so just treat it like a string\n this.message = error\n }\n }\n}\n","import { capitalize } from 'lodash'\n\nexport function humanizeErrors (errors) {\n return Object.entries(errors).reduce((errs, [k, val]) => {\n let message = val.reduce((acc, message) => {\n let key = capitalize(k.replace(/_/g, ' '))\n return acc + [key, message].join(' ') + '. '\n }, '')\n return [...errs, message]\n }, [])\n}\n","import backendInteractorService from '../services/backend_interactor_service/backend_interactor_service.js'\nimport oauthApi from '../services/new_api/oauth.js'\nimport { compact, map, each, merge, last, concat, uniq } from 'lodash'\nimport { set } from 'vue'\nimport { registerPushNotifications, unregisterPushNotifications } from '../services/push/push.js'\n\n// TODO: Unify with mergeOrAdd in statuses.js\nexport const mergeOrAdd = (arr, obj, item) => {\n if (!item) { return false }\n const oldItem = obj[item.id]\n if (oldItem) {\n // We already have this, so only merge the new info.\n merge(oldItem, item)\n return { item: oldItem, new: false }\n } else {\n // This is a new item, prepare it\n arr.push(item)\n set(obj, item.id, item)\n if (item.screen_name && !item.screen_name.includes('@')) {\n set(obj, item.screen_name.toLowerCase(), item)\n }\n return { item, new: true }\n }\n}\n\nconst getNotificationPermission = () => {\n const Notification = window.Notification\n\n if (!Notification) return Promise.resolve(null)\n if (Notification.permission === 'default') return Notification.requestPermission()\n return Promise.resolve(Notification.permission)\n}\n\nconst blockUser = (store, id) => {\n return store.rootState.api.backendInteractor.blockUser(id)\n .then((relationship) => {\n store.commit('updateUserRelationship', [relationship])\n store.commit('addBlockId', id)\n store.commit('removeStatus', { timeline: 'friends', userId: id })\n store.commit('removeStatus', { timeline: 'public', userId: id })\n store.commit('removeStatus', { timeline: 'publicAndExternal', userId: id })\n })\n}\n\nconst unblockUser = (store, id) => {\n return store.rootState.api.backendInteractor.unblockUser(id)\n .then((relationship) => store.commit('updateUserRelationship', [relationship]))\n}\n\nconst muteUser = (store, id) => {\n return store.rootState.api.backendInteractor.muteUser(id)\n .then((relationship) => {\n store.commit('updateUserRelationship', [relationship])\n store.commit('addMuteId', id)\n })\n}\n\nconst unmuteUser = (store, id) => {\n return store.rootState.api.backendInteractor.unmuteUser(id)\n .then((relationship) => store.commit('updateUserRelationship', [relationship]))\n}\n\nconst hideReblogs = (store, userId) => {\n return store.rootState.api.backendInteractor.followUser({ id: userId, reblogs: false })\n .then((relationship) => {\n store.commit('updateUserRelationship', [relationship])\n })\n}\n\nconst showReblogs = (store, userId) => {\n return store.rootState.api.backendInteractor.followUser({ id: userId, reblogs: true })\n .then((relationship) => store.commit('updateUserRelationship', [relationship]))\n}\n\nexport const mutations = {\n setMuted (state, { user: { id }, muted }) {\n const user = state.usersObject[id]\n set(user, 'muted', muted)\n },\n tagUser (state, { user: { id }, tag }) {\n const user = state.usersObject[id]\n const tags = user.tags || []\n const newTags = tags.concat([tag])\n set(user, 'tags', newTags)\n },\n untagUser (state, { user: { id }, tag }) {\n const user = state.usersObject[id]\n const tags = user.tags || []\n const newTags = tags.filter(t => t !== tag)\n set(user, 'tags', newTags)\n },\n updateRight (state, { user: { id }, right, value }) {\n const user = state.usersObject[id]\n let newRights = user.rights\n newRights[right] = value\n set(user, 'rights', newRights)\n },\n updateActivationStatus (state, { user: { id }, status }) {\n const user = state.usersObject[id]\n set(user, 'deactivated', !status)\n },\n setCurrentUser (state, user) {\n state.lastLoginName = user.screen_name\n state.currentUser = merge(state.currentUser || {}, user)\n },\n clearCurrentUser (state) {\n state.currentUser = false\n state.lastLoginName = false\n },\n beginLogin (state) {\n state.loggingIn = true\n },\n endLogin (state) {\n state.loggingIn = false\n },\n saveFriendIds (state, { id, friendIds }) {\n const user = state.usersObject[id]\n user.friendIds = uniq(concat(user.friendIds, friendIds))\n },\n saveFollowerIds (state, { id, followerIds }) {\n const user = state.usersObject[id]\n user.followerIds = uniq(concat(user.followerIds, followerIds))\n },\n // Because frontend doesn't have a reason to keep these stuff in memory\n // outside of viewing someones user profile.\n clearFriends (state, userId) {\n const user = state.usersObject[userId]\n if (user) {\n set(user, 'friendIds', [])\n }\n },\n clearFollowers (state, userId) {\n const user = state.usersObject[userId]\n if (user) {\n set(user, 'followerIds', [])\n }\n },\n addNewUsers (state, users) {\n each(users, (user) => mergeOrAdd(state.users, state.usersObject, user))\n },\n updateUserRelationship (state, relationships) {\n relationships.forEach((relationship) => {\n const user = state.usersObject[relationship.id]\n if (user) {\n user.follows_you = relationship.followed_by\n user.following = relationship.following\n user.muted = relationship.muting\n user.statusnet_blocking = relationship.blocking\n user.subscribed = relationship.subscribing\n user.showing_reblogs = relationship.showing_reblogs\n }\n })\n },\n updateBlocks (state, blockedUsers) {\n // Reset statusnet_blocking of all fetched users\n each(state.users, (user) => { user.statusnet_blocking = false })\n each(blockedUsers, (user) => mergeOrAdd(state.users, state.usersObject, user))\n },\n saveBlockIds (state, blockIds) {\n state.currentUser.blockIds = blockIds\n },\n addBlockId (state, blockId) {\n if (state.currentUser.blockIds.indexOf(blockId) === -1) {\n state.currentUser.blockIds.push(blockId)\n }\n },\n updateMutes (state, mutedUsers) {\n // Reset muted of all fetched users\n each(state.users, (user) => { user.muted = false })\n each(mutedUsers, (user) => mergeOrAdd(state.users, state.usersObject, user))\n },\n saveMuteIds (state, muteIds) {\n state.currentUser.muteIds = muteIds\n },\n addMuteId (state, muteId) {\n if (state.currentUser.muteIds.indexOf(muteId) === -1) {\n state.currentUser.muteIds.push(muteId)\n }\n },\n setPinnedToUser (state, status) {\n const user = state.usersObject[status.user.id]\n const index = user.pinnedStatusIds.indexOf(status.id)\n if (status.pinned && index === -1) {\n user.pinnedStatusIds.push(status.id)\n } else if (!status.pinned && index !== -1) {\n user.pinnedStatusIds.splice(index, 1)\n }\n },\n setUserForStatus (state, status) {\n status.user = state.usersObject[status.user.id]\n },\n setUserForNotification (state, notification) {\n if (notification.type !== 'follow') {\n notification.action.user = state.usersObject[notification.action.user.id]\n }\n notification.from_profile = state.usersObject[notification.from_profile.id]\n },\n setColor (state, { user: { id }, highlighted }) {\n const user = state.usersObject[id]\n set(user, 'highlight', highlighted)\n },\n signUpPending (state) {\n state.signUpPending = true\n state.signUpErrors = []\n },\n signUpSuccess (state) {\n state.signUpPending = false\n },\n signUpFailure (state, errors) {\n state.signUpPending = false\n state.signUpErrors = errors\n }\n}\n\nexport const getters = {\n findUser: state => query => {\n const result = state.usersObject[query]\n // In case it's a screen_name, we can try searching case-insensitive\n if (!result && typeof query === 'string') {\n return state.usersObject[query.toLowerCase()]\n }\n return result\n }\n}\n\nexport const defaultState = {\n loggingIn: false,\n lastLoginName: false,\n currentUser: false,\n users: [],\n usersObject: {},\n signUpPending: false,\n signUpErrors: []\n}\n\nconst users = {\n state: defaultState,\n mutations,\n getters,\n actions: {\n fetchUser (store, id) {\n return store.rootState.api.backendInteractor.fetchUser({ id })\n .then((user) => {\n store.commit('addNewUsers', [user])\n return user\n })\n },\n fetchUserRelationship (store, id) {\n if (store.state.currentUser) {\n store.rootState.api.backendInteractor.fetchUserRelationship({ id })\n .then((relationships) => store.commit('updateUserRelationship', relationships))\n }\n },\n fetchBlocks (store) {\n return store.rootState.api.backendInteractor.fetchBlocks()\n .then((blocks) => {\n store.commit('saveBlockIds', map(blocks, 'id'))\n store.commit('updateBlocks', blocks)\n return blocks\n })\n },\n blockUser (store, id) {\n return blockUser(store, id)\n },\n unblockUser (store, id) {\n return unblockUser(store, id)\n },\n blockUsers (store, ids = []) {\n return Promise.all(ids.map(id => blockUser(store, id)))\n },\n unblockUsers (store, ids = []) {\n return Promise.all(ids.map(id => unblockUser(store, id)))\n },\n fetchMutes (store) {\n return store.rootState.api.backendInteractor.fetchMutes()\n .then((mutes) => {\n store.commit('updateMutes', mutes)\n store.commit('saveMuteIds', map(mutes, 'id'))\n return mutes\n })\n },\n muteUser (store, id) {\n return muteUser(store, id)\n },\n unmuteUser (store, id) {\n return unmuteUser(store, id)\n },\n hideReblogs (store, id) {\n return hideReblogs(store, id)\n },\n showReblogs (store, id) {\n return showReblogs(store, id)\n },\n muteUsers (store, ids = []) {\n return Promise.all(ids.map(id => muteUser(store, id)))\n },\n unmuteUsers (store, ids = []) {\n return Promise.all(ids.map(id => unmuteUser(store, id)))\n },\n fetchFriends ({ rootState, commit }, id) {\n const user = rootState.users.usersObject[id]\n const maxId = last(user.friendIds)\n return rootState.api.backendInteractor.fetchFriends({ id, maxId })\n .then((friends) => {\n commit('addNewUsers', friends)\n commit('saveFriendIds', { id, friendIds: map(friends, 'id') })\n return friends\n })\n },\n fetchFollowers ({ rootState, commit }, id) {\n const user = rootState.users.usersObject[id]\n const maxId = last(user.followerIds)\n return rootState.api.backendInteractor.fetchFollowers({ id, maxId })\n .then((followers) => {\n commit('addNewUsers', followers)\n commit('saveFollowerIds', { id, followerIds: map(followers, 'id') })\n return followers\n })\n },\n clearFriends ({ commit }, userId) {\n commit('clearFriends', userId)\n },\n clearFollowers ({ commit }, userId) {\n commit('clearFollowers', userId)\n },\n subscribeUser ({ rootState, commit }, id) {\n return rootState.api.backendInteractor.subscribeUser(id)\n .then((relationship) => commit('updateUserRelationship', [relationship]))\n },\n unsubscribeUser ({ rootState, commit }, id) {\n return rootState.api.backendInteractor.unsubscribeUser(id)\n .then((relationship) => commit('updateUserRelationship', [relationship]))\n },\n registerPushNotifications (store) {\n const token = store.state.currentUser.credentials\n const vapidPublicKey = store.rootState.instance.vapidPublicKey\n const isEnabled = store.rootState.config.webPushNotifications\n const notificationVisibility = store.rootState.config.notificationVisibility\n\n registerPushNotifications(isEnabled, vapidPublicKey, token, notificationVisibility)\n },\n unregisterPushNotifications (store) {\n const token = store.state.currentUser.credentials\n\n unregisterPushNotifications(token)\n },\n addNewUsers ({ commit }, users) {\n commit('addNewUsers', users)\n },\n addNewStatuses (store, { statuses }) {\n const users = map(statuses, 'user')\n const retweetedUsers = compact(map(statuses, 'retweeted_status.user'))\n store.commit('addNewUsers', users)\n store.commit('addNewUsers', retweetedUsers)\n\n each(statuses, (status) => {\n // Reconnect users to statuses\n store.commit('setUserForStatus', status)\n // Set pinned statuses to user\n store.commit('setPinnedToUser', status)\n })\n each(compact(map(statuses, 'retweeted_status')), (status) => {\n // Reconnect users to retweets\n store.commit('setUserForStatus', status)\n // Set pinned retweets to user\n store.commit('setPinnedToUser', status)\n })\n },\n addNewNotifications (store, { notifications }) {\n const users = map(notifications, 'from_profile')\n const notificationIds = notifications.map(_ => _.id)\n store.commit('addNewUsers', users)\n\n const notificationsObject = store.rootState.statuses.notifications.idStore\n const relevantNotifications = Object.entries(notificationsObject)\n .filter(([k, val]) => notificationIds.includes(k))\n .map(([k, val]) => val)\n\n // Reconnect users to notifications\n each(relevantNotifications, (notification) => {\n store.commit('setUserForNotification', notification)\n })\n },\n searchUsers (store, query) {\n return store.rootState.api.backendInteractor.searchUsers(query)\n .then((users) => {\n store.commit('addNewUsers', users)\n return users\n })\n },\n async signUp (store, userInfo) {\n store.commit('signUpPending')\n\n let rootState = store.rootState\n\n try {\n let data = await rootState.api.backendInteractor.register(userInfo)\n store.commit('signUpSuccess')\n store.commit('setToken', data.access_token)\n store.dispatch('loginUser', data.access_token)\n } catch (e) {\n let errors = e.message\n store.commit('signUpFailure', errors)\n throw e\n }\n },\n async getCaptcha (store) {\n return store.rootState.api.backendInteractor.getCaptcha()\n },\n\n logout (store) {\n const { oauth, instance } = store.rootState\n\n const data = {\n ...oauth,\n commit: store.commit,\n instance: instance.server\n }\n\n return oauthApi.getOrCreateApp(data)\n .then((app) => {\n const params = {\n app,\n instance: data.instance,\n token: oauth.userToken\n }\n\n return oauthApi.revokeToken(params)\n })\n .then(() => {\n store.commit('clearCurrentUser')\n store.dispatch('disconnectFromSocket')\n store.commit('clearToken')\n store.dispatch('stopFetching', 'friends')\n store.commit('setBackendInteractor', backendInteractorService(store.getters.getToken()))\n store.dispatch('stopFetching', 'notifications')\n store.commit('clearNotifications')\n store.commit('resetStatuses')\n })\n },\n loginUser (store, accessToken) {\n return new Promise((resolve, reject) => {\n const commit = store.commit\n commit('beginLogin')\n store.rootState.api.backendInteractor.verifyCredentials(accessToken)\n .then((data) => {\n if (!data.error) {\n const user = data\n // user.credentials = userCredentials\n user.credentials = accessToken\n user.blockIds = []\n user.muteIds = []\n commit('setCurrentUser', user)\n commit('addNewUsers', [user])\n\n store.dispatch('fetchEmoji')\n\n getNotificationPermission()\n .then(permission => commit('setNotificationPermission', permission))\n\n // Set our new backend interactor\n commit('setBackendInteractor', backendInteractorService(accessToken))\n\n if (user.token) {\n store.dispatch('setWsToken', user.token)\n\n // Initialize the chat socket.\n store.dispatch('initializeSocket')\n }\n\n // Start getting fresh posts.\n store.dispatch('startFetchingTimeline', { timeline: 'friends' })\n\n // Start fetching notifications\n store.dispatch('startFetchingNotifications')\n\n // Get user mutes\n store.dispatch('fetchMutes')\n\n // Fetch our friends\n store.rootState.api.backendInteractor.fetchFriends({ id: user.id })\n .then((friends) => commit('addNewUsers', friends))\n } else {\n const response = data.error\n // Authentication failed\n commit('endLogin')\n if (response.status === 401) {\n reject(new Error('Wrong username or password'))\n } else {\n reject(new Error('An error occurred, please try again'))\n }\n }\n commit('endLogin')\n resolve()\n })\n .catch((error) => {\n console.log(error)\n commit('endLogin')\n reject(new Error('Failed to connect to server, try again'))\n })\n })\n }\n }\n}\n\nexport default users\n","import runtime from 'serviceworker-webpack-plugin/lib/runtime'\n\nfunction urlBase64ToUint8Array (base64String) {\n const padding = '='.repeat((4 - base64String.length % 4) % 4)\n const base64 = (base64String + padding)\n .replace(/-/g, '+')\n .replace(/_/g, '/')\n\n const rawData = window.atob(base64)\n return Uint8Array.from([...rawData].map((char) => char.charCodeAt(0)))\n}\n\nfunction isPushSupported () {\n return 'serviceWorker' in navigator && 'PushManager' in window\n}\n\nfunction getOrCreateServiceWorker () {\n return runtime.register()\n .catch((err) => console.error('Unable to get or create a service worker.', err))\n}\n\nfunction subscribePush (registration, isEnabled, vapidPublicKey) {\n if (!isEnabled) return Promise.reject(new Error('Web Push is disabled in config'))\n if (!vapidPublicKey) return Promise.reject(new Error('VAPID public key is not found'))\n\n const subscribeOptions = {\n userVisibleOnly: true,\n applicationServerKey: urlBase64ToUint8Array(vapidPublicKey)\n }\n return registration.pushManager.subscribe(subscribeOptions)\n}\n\nfunction unsubscribePush (registration) {\n return registration.pushManager.getSubscription()\n .then((subscribtion) => {\n if (subscribtion === null) { return }\n return subscribtion.unsubscribe()\n })\n}\n\nfunction deleteSubscriptionFromBackEnd (token) {\n return window.fetch('/api/v1/push/subscription/', {\n method: 'DELETE',\n headers: {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${token}`\n }\n }).then((response) => {\n if (!response.ok) throw new Error('Bad status code from server.')\n return response\n })\n}\n\nfunction sendSubscriptionToBackEnd (subscription, token, notificationVisibility) {\n return window.fetch('/api/v1/push/subscription/', {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${token}`\n },\n body: JSON.stringify({\n subscription,\n data: {\n alerts: {\n follow: notificationVisibility.follows,\n favourite: notificationVisibility.likes,\n mention: notificationVisibility.mentions,\n reblog: notificationVisibility.repeats\n }\n }\n })\n }).then((response) => {\n if (!response.ok) throw new Error('Bad status code from server.')\n return response.json()\n }).then((responseData) => {\n if (!responseData.id) throw new Error('Bad response from server.')\n return responseData\n })\n}\n\nexport function registerPushNotifications (isEnabled, vapidPublicKey, token, notificationVisibility) {\n if (isPushSupported()) {\n getOrCreateServiceWorker()\n .then((registration) => subscribePush(registration, isEnabled, vapidPublicKey))\n .then((subscription) => sendSubscriptionToBackEnd(subscription, token, notificationVisibility))\n .catch((e) => console.warn(`Failed to setup Web Push Notifications: ${e.message}`))\n }\n}\n\nexport function unregisterPushNotifications (token) {\n if (isPushSupported()) {\n Promise.all([\n deleteSubscriptionFromBackEnd(token),\n getOrCreateServiceWorker()\n .then((registration) => {\n return unsubscribePush(registration).then((result) => [registration, result])\n })\n .then(([registration, unsubResult]) => {\n if (!unsubResult) {\n console.warn('Push subscription cancellation wasn\\'t successful, killing SW anyway...')\n }\n return registration.unregister().then((result) => {\n if (!result) {\n console.warn('Failed to kill SW')\n }\n })\n })\n ]).catch((e) => console.warn(`Failed to disable Web Push Notifications: ${e.message}`))\n }\n}\n","import backendInteractorService from '../services/backend_interactor_service/backend_interactor_service.js'\nimport { Socket } from 'phoenix'\n\nconst api = {\n state: {\n backendInteractor: backendInteractorService(),\n fetchers: {},\n socket: null,\n followRequests: []\n },\n mutations: {\n setBackendInteractor (state, backendInteractor) {\n state.backendInteractor = backendInteractor\n },\n addFetcher (state, { fetcherName, fetcher }) {\n state.fetchers[fetcherName] = fetcher\n },\n removeFetcher (state, { fetcherName }) {\n delete state.fetchers[fetcherName]\n },\n setWsToken (state, token) {\n state.wsToken = token\n },\n setSocket (state, socket) {\n state.socket = socket\n },\n setFollowRequests (state, value) {\n state.followRequests = value\n }\n },\n actions: {\n startFetchingTimeline (store, { timeline = 'friends', tag = false, userId = false }) {\n // Don't start fetching if we already are.\n if (store.state.fetchers[timeline]) return\n\n const fetcher = store.state.backendInteractor.startFetchingTimeline({ timeline, store, userId, tag })\n store.commit('addFetcher', { fetcherName: timeline, fetcher })\n },\n startFetchingNotifications (store) {\n // Don't start fetching if we already are.\n if (store.state.fetchers['notifications']) return\n\n const fetcher = store.state.backendInteractor.startFetchingNotifications({ store })\n store.commit('addFetcher', { fetcherName: 'notifications', fetcher })\n },\n stopFetching (store, fetcherName) {\n const fetcher = store.state.fetchers[fetcherName]\n window.clearInterval(fetcher)\n store.commit('removeFetcher', { fetcherName })\n },\n setWsToken (store, token) {\n store.commit('setWsToken', token)\n },\n initializeSocket ({ dispatch, commit, state, rootState }) {\n // Set up websocket connection\n const token = state.wsToken\n if (rootState.instance.chatAvailable && typeof token !== 'undefined' && state.socket === null) {\n const socket = new Socket('/socket', { params: { token } })\n socket.connect()\n\n commit('setSocket', socket)\n dispatch('initializeChat', socket)\n }\n },\n disconnectFromSocket ({ commit, state }) {\n state.socket && state.socket.disconnect()\n commit('setSocket', null)\n },\n removeFollowRequest (store, request) {\n let requests = store.state.followRequests.filter((it) => it !== request)\n store.commit('setFollowRequests', requests)\n }\n }\n}\n\nexport default api\n","const chat = {\n state: {\n messages: [],\n channel: { state: '' }\n },\n mutations: {\n setChannel (state, channel) {\n state.channel = channel\n },\n addMessage (state, message) {\n state.messages.push(message)\n state.messages = state.messages.slice(-19, 20)\n },\n setMessages (state, messages) {\n state.messages = messages.slice(-19, 20)\n }\n },\n actions: {\n initializeChat (store, socket) {\n const channel = socket.channel('chat:public')\n channel.on('new_msg', (msg) => {\n store.commit('addMessage', msg)\n })\n channel.on('messages', ({ messages }) => {\n store.commit('setMessages', messages)\n })\n channel.join()\n store.commit('setChannel', channel)\n }\n }\n}\n\nexport default chat\n","import { delete as del } from 'vue'\n\nconst oauth = {\n state: {\n clientId: false,\n clientSecret: false,\n /* App token is authentication for app without any user, used mostly for\n * MastoAPI's registration of new users, stored so that we can fall back to\n * it on logout\n */\n appToken: false,\n /* User token is authentication for app with user, this is for every calls\n * that need authorized user to be successful (i.e. posting, liking etc)\n */\n userToken: false\n },\n mutations: {\n setClientData (state, { clientId, clientSecret }) {\n state.clientId = clientId\n state.clientSecret = clientSecret\n },\n setAppToken (state, token) {\n state.appToken = token\n },\n setToken (state, token) {\n state.userToken = token\n },\n clearToken (state) {\n state.userToken = false\n // state.token is userToken with older name, coming from persistent state\n // let's clear it as well, since it is being used as a fallback of state.userToken\n del(state, 'token')\n }\n },\n getters: {\n getToken: state => () => {\n // state.token is userToken with older name, coming from persistent state\n // added here for smoother transition, otherwise user will be logged out\n return state.userToken || state.token || state.appToken\n },\n getUserToken: state => () => {\n // state.token is userToken with older name, coming from persistent state\n // added here for smoother transition, otherwise user will be logged out\n return state.userToken || state.token\n }\n }\n}\n\nexport default oauth\n","const PASSWORD_STRATEGY = 'password'\nconst TOKEN_STRATEGY = 'token'\n\n// MFA strategies\nconst TOTP_STRATEGY = 'totp'\nconst RECOVERY_STRATEGY = 'recovery'\n\n// initial state\nconst state = {\n app: null,\n settings: {},\n strategy: PASSWORD_STRATEGY,\n initStrategy: PASSWORD_STRATEGY // default strategy from config\n}\n\nconst resetState = (state) => {\n state.strategy = state.initStrategy\n state.settings = {}\n state.app = null\n}\n\n// getters\nconst getters = {\n app: (state, getters) => {\n return state.app\n },\n settings: (state, getters) => {\n return state.settings\n },\n requiredPassword: (state, getters, rootState) => {\n return state.strategy === PASSWORD_STRATEGY\n },\n requiredToken: (state, getters, rootState) => {\n return state.strategy === TOKEN_STRATEGY\n },\n requiredTOTP: (state, getters, rootState) => {\n return state.strategy === TOTP_STRATEGY\n },\n requiredRecovery: (state, getters, rootState) => {\n return state.strategy === RECOVERY_STRATEGY\n }\n}\n\n// mutations\nconst mutations = {\n setInitialStrategy (state, strategy) {\n if (strategy) {\n state.initStrategy = strategy\n state.strategy = strategy\n }\n },\n requirePassword (state) {\n state.strategy = PASSWORD_STRATEGY\n },\n requireToken (state) {\n state.strategy = TOKEN_STRATEGY\n },\n requireMFA (state, { app, settings }) {\n state.settings = settings\n state.app = app\n state.strategy = TOTP_STRATEGY // default strategy of MFA\n },\n requireRecovery (state) {\n state.strategy = RECOVERY_STRATEGY\n },\n requireTOTP (state) {\n state.strategy = TOTP_STRATEGY\n },\n abortMFA (state) {\n resetState(state)\n }\n}\n\n// actions\nconst actions = {\n // eslint-disable-next-line camelcase\n async login ({ state, dispatch, commit }, { access_token }) {\n commit('setToken', access_token, { root: true })\n await dispatch('loginUser', access_token, { root: true })\n resetState(state)\n }\n}\n\nexport default {\n namespaced: true,\n state,\n getters,\n mutations,\n actions\n}\n","import fileTypeService from '../services/file_type/file_type.service.js'\n\nconst mediaViewer = {\n state: {\n media: [],\n currentIndex: 0,\n activated: false\n },\n mutations: {\n setMedia (state, media) {\n state.media = media\n },\n setCurrent (state, index) {\n state.activated = true\n state.currentIndex = index\n },\n close (state) {\n state.activated = false\n }\n },\n actions: {\n setMedia ({ commit }, attachments) {\n const media = attachments.filter(attachment => {\n const type = fileTypeService.fileType(attachment.mimetype)\n return type === 'image' || type === 'video'\n })\n commit('setMedia', media)\n },\n setCurrent ({ commit, state }, current) {\n const index = state.media.indexOf(current)\n commit('setCurrent', index || 0)\n },\n closeMediaViewer ({ commit }) {\n commit('close')\n }\n }\n}\n\nexport default mediaViewer\n","const oauthTokens = {\n state: {\n tokens: []\n },\n actions: {\n fetchTokens ({ rootState, commit }) {\n rootState.api.backendInteractor.fetchOAuthTokens().then((tokens) => {\n commit('swapTokens', tokens)\n })\n },\n revokeToken ({ rootState, commit, state }, id) {\n rootState.api.backendInteractor.revokeOAuthToken(id).then((response) => {\n if (response.status === 201) {\n commit('swapTokens', state.tokens.filter(token => token.id !== id))\n }\n })\n }\n },\n mutations: {\n swapTokens (state, tokens) {\n state.tokens = tokens\n }\n }\n}\n\nexport default oauthTokens\n","import filter from 'lodash/filter'\n\nconst reports = {\n state: {\n userId: null,\n statuses: [],\n modalActivated: false\n },\n mutations: {\n openUserReportingModal (state, { userId, statuses }) {\n state.userId = userId\n state.statuses = statuses\n state.modalActivated = true\n },\n closeUserReportingModal (state) {\n state.modalActivated = false\n }\n },\n actions: {\n openUserReportingModal ({ rootState, commit }, userId) {\n const statuses = filter(rootState.statuses.allStatuses, status => status.user.id === userId)\n commit('openUserReportingModal', { userId, statuses })\n },\n closeUserReportingModal ({ commit }) {\n commit('closeUserReportingModal')\n }\n }\n}\n\nexport default reports\n","import { merge } from 'lodash'\nimport { set } from 'vue'\n\nconst polls = {\n state: {\n // Contains key = id, value = number of trackers for this poll\n trackedPolls: {},\n pollsObject: {}\n },\n mutations: {\n mergeOrAddPoll (state, poll) {\n const existingPoll = state.pollsObject[poll.id]\n // Make expired-state change trigger re-renders properly\n poll.expired = Date.now() > Date.parse(poll.expires_at)\n if (existingPoll) {\n set(state.pollsObject, poll.id, merge(existingPoll, poll))\n } else {\n set(state.pollsObject, poll.id, poll)\n }\n },\n trackPoll (state, pollId) {\n const currentValue = state.trackedPolls[pollId]\n if (currentValue) {\n set(state.trackedPolls, pollId, currentValue + 1)\n } else {\n set(state.trackedPolls, pollId, 1)\n }\n },\n untrackPoll (state, pollId) {\n const currentValue = state.trackedPolls[pollId]\n if (currentValue) {\n set(state.trackedPolls, pollId, currentValue - 1)\n } else {\n set(state.trackedPolls, pollId, 0)\n }\n }\n },\n actions: {\n mergeOrAddPoll ({ commit }, poll) {\n commit('mergeOrAddPoll', poll)\n },\n updateTrackedPoll ({ rootState, dispatch, commit }, pollId) {\n rootState.api.backendInteractor.fetchPoll(pollId).then(poll => {\n setTimeout(() => {\n if (rootState.polls.trackedPolls[pollId]) {\n dispatch('updateTrackedPoll', pollId)\n }\n }, 30 * 1000)\n commit('mergeOrAddPoll', poll)\n })\n },\n trackPoll ({ rootState, commit, dispatch }, pollId) {\n if (!rootState.polls.trackedPolls[pollId]) {\n setTimeout(() => dispatch('updateTrackedPoll', pollId), 30 * 1000)\n }\n commit('trackPoll', pollId)\n },\n untrackPoll ({ commit }, pollId) {\n commit('untrackPoll', pollId)\n },\n votePoll ({ rootState, commit }, { id, pollId, choices }) {\n return rootState.api.backendInteractor.vote(pollId, choices).then(poll => {\n commit('mergeOrAddPoll', poll)\n return poll\n })\n }\n }\n}\n\nexport default polls\n","const postStatus = {\n state: {\n params: null,\n modalActivated: false\n },\n mutations: {\n openPostStatusModal (state, params) {\n state.params = params\n state.modalActivated = true\n },\n closePostStatusModal (state) {\n state.modalActivated = false\n }\n },\n actions: {\n openPostStatusModal ({ commit }, params) {\n commit('openPostStatusModal', params)\n },\n closePostStatusModal ({ commit }) {\n commit('closePostStatusModal')\n }\n }\n}\n\nexport default postStatus\n","import merge from 'lodash.merge'\nimport objectPath from 'object-path'\nimport localforage from 'localforage'\nimport { each } from 'lodash'\n\nlet loaded = false\n\nconst defaultReducer = (state, paths) => (\n paths.length === 0 ? state : paths.reduce((substate, path) => {\n objectPath.set(substate, path, objectPath.get(state, path))\n return substate\n }, {})\n)\n\nconst saveImmedeatelyActions = [\n 'markNotificationsAsSeen',\n 'clearCurrentUser',\n 'setCurrentUser',\n 'setHighlight',\n 'setOption',\n 'setClientData',\n 'setToken',\n 'clearToken'\n]\n\nconst defaultStorage = (() => {\n return localforage\n})()\n\nexport default function createPersistedState ({\n key = 'vuex-lz',\n paths = [],\n getState = (key, storage) => {\n let value = storage.getItem(key)\n return value\n },\n setState = (key, state, storage) => {\n if (!loaded) {\n console.log('waiting for old state to be loaded...')\n return Promise.resolve()\n } else {\n return storage.setItem(key, state)\n }\n },\n reducer = defaultReducer,\n storage = defaultStorage,\n subscriber = store => handler => store.subscribe(handler)\n} = {}) {\n return getState(key, storage).then((savedState) => {\n return store => {\n try {\n if (savedState !== null && typeof savedState === 'object') {\n // build user cache\n const usersState = savedState.users || {}\n usersState.usersObject = {}\n const users = usersState.users || []\n each(users, (user) => { usersState.usersObject[user.id] = user })\n savedState.users = usersState\n\n store.replaceState(\n merge({}, store.state, savedState)\n )\n }\n loaded = true\n } catch (e) {\n console.log(\"Couldn't load state\")\n console.error(e)\n loaded = true\n }\n subscriber(store)((mutation, state) => {\n try {\n if (saveImmedeatelyActions.includes(mutation.type)) {\n setState(key, reducer(state, paths), storage)\n .then(success => {\n if (typeof success !== 'undefined') {\n if (mutation.type === 'setOption' || mutation.type === 'setCurrentUser') {\n store.dispatch('settingsSaved', { success })\n }\n }\n }, error => {\n if (mutation.type === 'setOption' || mutation.type === 'setCurrentUser') {\n store.dispatch('settingsSaved', { error })\n }\n })\n }\n } catch (e) {\n console.log(\"Couldn't persist state:\")\n console.log(e)\n }\n })\n }\n })\n}\n","export default (store) => {\n store.subscribe((mutation, state) => {\n const vapidPublicKey = state.instance.vapidPublicKey\n const webPushNotification = state.config.webPushNotifications\n const permission = state.interface.notificationPermission === 'granted'\n const user = state.users.currentUser\n\n const isUserMutation = mutation.type === 'setCurrentUser'\n const isVapidMutation = mutation.type === 'setInstanceOption' && mutation.payload.name === 'vapidPublicKey'\n const isPermMutation = mutation.type === 'setNotificationPermission' && mutation.payload === 'granted'\n const isUserConfigMutation = mutation.type === 'setOption' && mutation.payload.name === 'webPushNotifications'\n const isVisibilityMutation = mutation.type === 'setOption' && mutation.payload.name === 'notificationVisibility'\n\n if (isUserMutation || isVapidMutation || isPermMutation || isUserConfigMutation || isVisibilityMutation) {\n if (user && vapidPublicKey && permission && webPushNotification) {\n return store.dispatch('registerPushNotifications')\n } else if (isUserConfigMutation && !webPushNotification) {\n return store.dispatch('unregisterPushNotifications')\n }\n }\n })\n}\n","import * as bodyScrollLock from 'body-scroll-lock'\n\nlet previousNavPaddingRight\nlet previousAppBgWrapperRight\nconst lockerEls = new Set([])\n\nconst disableBodyScroll = (el) => {\n const scrollBarGap = window.innerWidth - document.documentElement.clientWidth\n bodyScrollLock.disableBodyScroll(el, {\n reserveScrollBarGap: true\n })\n lockerEls.add(el)\n setTimeout(() => {\n if (lockerEls.size <= 1) {\n // If previousNavPaddingRight is already set, don't set it again.\n if (previousNavPaddingRight === undefined) {\n const navEl = document.getElementById('nav')\n previousNavPaddingRight = window.getComputedStyle(navEl).getPropertyValue('padding-right')\n navEl.style.paddingRight = previousNavPaddingRight ? `calc(${previousNavPaddingRight} + ${scrollBarGap}px)` : `${scrollBarGap}px`\n }\n // If previousAppBgWrapeprRight is already set, don't set it again.\n if (previousAppBgWrapperRight === undefined) {\n const appBgWrapperEl = document.getElementById('app_bg_wrapper')\n previousAppBgWrapperRight = window.getComputedStyle(appBgWrapperEl).getPropertyValue('right')\n appBgWrapperEl.style.right = previousAppBgWrapperRight ? `calc(${previousAppBgWrapperRight} + ${scrollBarGap}px)` : `${scrollBarGap}px`\n }\n document.body.classList.add('scroll-locked')\n }\n })\n}\n\nconst enableBodyScroll = (el) => {\n lockerEls.delete(el)\n setTimeout(() => {\n if (lockerEls.size === 0) {\n if (previousNavPaddingRight !== undefined) {\n document.getElementById('nav').style.paddingRight = previousNavPaddingRight\n // Restore previousNavPaddingRight to undefined so disableBodyScroll knows it can be set again.\n previousNavPaddingRight = undefined\n }\n if (previousAppBgWrapperRight !== undefined) {\n document.getElementById('app_bg_wrapper').style.right = previousAppBgWrapperRight\n // Restore previousAppBgWrapperRight to undefined so disableBodyScroll knows it can be set again.\n previousAppBgWrapperRight = undefined\n }\n document.body.classList.remove('scroll-locked')\n }\n })\n bodyScrollLock.enableBodyScroll(el)\n}\n\nconst directive = {\n inserted: (el, binding) => {\n if (binding.value) {\n disableBodyScroll(el)\n }\n },\n componentUpdated: (el, binding) => {\n if (binding.oldValue === binding.value) {\n return\n }\n\n if (binding.value) {\n disableBodyScroll(el)\n } else {\n enableBodyScroll(el)\n }\n },\n unbind: (el) => {\n enableBodyScroll(el)\n }\n}\n\nexport default (Vue) => {\n Vue.directive('body-scroll-lock', directive)\n}\n","import Vue from 'vue'\nimport VueRouter from 'vue-router'\nimport routes from './routes'\nimport App from '../App.vue'\nimport { windowWidth } from '../services/window_utils/window_utils'\nimport { getOrCreateApp, getClientToken } from '../services/new_api/oauth.js'\nimport backendInteractorService from '../services/backend_interactor_service/backend_interactor_service.js'\n\nconst getStatusnetConfig = async ({ store }) => {\n try {\n const res = await window.fetch('/api/statusnet/config.json')\n if (res.ok) {\n const data = await res.json()\n const { name, closed: registrationClosed, textlimit, uploadlimit, server, vapidPublicKey, safeDMMentionsEnabled } = data.site\n\n store.dispatch('setInstanceOption', { name: 'name', value: name })\n store.dispatch('setInstanceOption', { name: 'registrationOpen', value: (registrationClosed === '0') })\n store.dispatch('setInstanceOption', { name: 'textlimit', value: parseInt(textlimit) })\n store.dispatch('setInstanceOption', { name: 'server', value: server })\n store.dispatch('setInstanceOption', { name: 'safeDM', value: safeDMMentionsEnabled !== '0' })\n\n // TODO: default values for this stuff, added if to not make it break on\n // my dev config out of the box.\n if (uploadlimit) {\n store.dispatch('setInstanceOption', { name: 'uploadlimit', value: parseInt(uploadlimit.uploadlimit) })\n store.dispatch('setInstanceOption', { name: 'avatarlimit', value: parseInt(uploadlimit.avatarlimit) })\n store.dispatch('setInstanceOption', { name: 'backgroundlimit', value: parseInt(uploadlimit.backgroundlimit) })\n store.dispatch('setInstanceOption', { name: 'bannerlimit', value: parseInt(uploadlimit.bannerlimit) })\n }\n\n if (vapidPublicKey) {\n store.dispatch('setInstanceOption', { name: 'vapidPublicKey', value: vapidPublicKey })\n }\n\n return data.site.pleromafe\n } else {\n throw (res)\n }\n } catch (error) {\n console.error('Could not load statusnet config, potentially fatal')\n console.error(error)\n }\n}\n\nconst getStaticConfig = async () => {\n try {\n const res = await window.fetch('/static/config.json')\n if (res.ok) {\n return res.json()\n } else {\n throw (res)\n }\n } catch (error) {\n console.warn('Failed to load static/config.json, continuing without it.')\n console.warn(error)\n return {}\n }\n}\n\nconst setSettings = async ({ apiConfig, staticConfig, store }) => {\n const overrides = window.___pleromafe_dev_overrides || {}\n const env = window.___pleromafe_mode.NODE_ENV\n\n // This takes static config and overrides properties that are present in apiConfig\n let config = {}\n if (overrides.staticConfigPreference && env === 'development') {\n console.warn('OVERRIDING API CONFIG WITH STATIC CONFIG')\n config = Object.assign({}, apiConfig, staticConfig)\n } else {\n config = Object.assign({}, staticConfig, apiConfig)\n }\n\n const copyInstanceOption = (name) => {\n store.dispatch('setInstanceOption', { name, value: config[name] })\n }\n\n copyInstanceOption('nsfwCensorImage')\n copyInstanceOption('background')\n copyInstanceOption('hidePostStats')\n copyInstanceOption('hideUserStats')\n copyInstanceOption('hideFilteredStatuses')\n copyInstanceOption('logo')\n\n store.dispatch('setInstanceOption', {\n name: 'logoMask',\n value: typeof config.logoMask === 'undefined'\n ? true\n : config.logoMask\n })\n\n store.dispatch('setInstanceOption', {\n name: 'logoMargin',\n value: typeof config.logoMargin === 'undefined'\n ? 0\n : config.logoMargin\n })\n store.commit('authFlow/setInitialStrategy', config.loginMethod)\n\n copyInstanceOption('redirectRootNoLogin')\n copyInstanceOption('redirectRootLogin')\n copyInstanceOption('showInstanceSpecificPanel')\n copyInstanceOption('minimalScopesMode')\n copyInstanceOption('hideMutedPosts')\n copyInstanceOption('collapseMessageWithSubject')\n copyInstanceOption('scopeCopy')\n copyInstanceOption('subjectLineBehavior')\n copyInstanceOption('postContentType')\n copyInstanceOption('alwaysShowSubjectInput')\n copyInstanceOption('noAttachmentLinks')\n copyInstanceOption('showFeaturesPanel')\n\n return store.dispatch('setTheme', config['theme'])\n}\n\nconst getTOS = async ({ store }) => {\n try {\n const res = await window.fetch('/static/terms-of-service.html')\n if (res.ok) {\n const html = await res.text()\n store.dispatch('setInstanceOption', { name: 'tos', value: html })\n } else {\n throw (res)\n }\n } catch (e) {\n console.warn(\"Can't load TOS\")\n console.warn(e)\n }\n}\n\nconst getInstancePanel = async ({ store }) => {\n try {\n const res = await window.fetch('/instance/panel.html')\n if (res.ok) {\n const html = await res.text()\n store.dispatch('setInstanceOption', { name: 'instanceSpecificPanelContent', value: html })\n } else {\n throw (res)\n }\n } catch (e) {\n console.warn(\"Can't load instance panel\")\n console.warn(e)\n }\n}\n\nconst getStickers = async ({ store }) => {\n try {\n const res = await window.fetch('/static/stickers.json')\n if (res.ok) {\n const values = await res.json()\n const stickers = (await Promise.all(\n Object.entries(values).map(async ([name, path]) => {\n const resPack = await window.fetch(path + 'pack.json')\n var meta = {}\n if (resPack.ok) {\n meta = await resPack.json()\n }\n return {\n pack: name,\n path,\n meta\n }\n })\n )).sort((a, b) => {\n return a.meta.title.localeCompare(b.meta.title)\n })\n store.dispatch('setInstanceOption', { name: 'stickers', value: stickers })\n } else {\n throw (res)\n }\n } catch (e) {\n console.warn(\"Can't load stickers\")\n console.warn(e)\n }\n}\n\nconst getAppSecret = async ({ store }) => {\n const { state, commit } = store\n const { oauth, instance } = state\n return getOrCreateApp({ ...oauth, instance: instance.server, commit })\n .then((app) => getClientToken({ ...app, instance: instance.server }))\n .then((token) => {\n commit('setAppToken', token.access_token)\n commit('setBackendInteractor', backendInteractorService(store.getters.getToken()))\n })\n}\n\nconst getNodeInfo = async ({ store }) => {\n try {\n const res = await window.fetch('/nodeinfo/2.0.json')\n if (res.ok) {\n const data = await res.json()\n const metadata = data.metadata\n const features = metadata.features\n store.dispatch('setInstanceOption', { name: 'mediaProxyAvailable', value: features.includes('media_proxy') })\n store.dispatch('setInstanceOption', { name: 'chatAvailable', value: features.includes('chat') })\n store.dispatch('setInstanceOption', { name: 'gopherAvailable', value: features.includes('gopher') })\n store.dispatch('setInstanceOption', { name: 'pollsAvailable', value: features.includes('polls') })\n store.dispatch('setInstanceOption', { name: 'pollLimits', value: metadata.pollLimits })\n store.dispatch('setInstanceOption', { name: 'mailerEnabled', value: metadata.mailerEnabled })\n\n store.dispatch('setInstanceOption', { name: 'restrictedNicknames', value: metadata.restrictedNicknames })\n store.dispatch('setInstanceOption', { name: 'postFormats', value: metadata.postFormats })\n\n const suggestions = metadata.suggestions\n store.dispatch('setInstanceOption', { name: 'suggestionsEnabled', value: suggestions.enabled })\n store.dispatch('setInstanceOption', { name: 'suggestionsWeb', value: suggestions.web })\n\n const software = data.software\n store.dispatch('setInstanceOption', { name: 'backendVersion', value: software.version })\n store.dispatch('setInstanceOption', { name: 'pleromaBackend', value: software.name === 'pleroma' })\n\n const frontendVersion = window.___pleromafe_commit_hash\n store.dispatch('setInstanceOption', { name: 'frontendVersion', value: frontendVersion })\n store.dispatch('setInstanceOption', { name: 'tagPolicyAvailable', value: metadata.federation.mrf_policies.includes('TagPolicy') })\n } else {\n throw (res)\n }\n } catch (e) {\n console.warn('Could not load nodeinfo')\n console.warn(e)\n }\n}\n\nconst setConfig = async ({ store }) => {\n // apiConfig, staticConfig\n const configInfos = await Promise.all([getStatusnetConfig({ store }), getStaticConfig()])\n const apiConfig = configInfos[0]\n const staticConfig = configInfos[1]\n\n await setSettings({ store, apiConfig, staticConfig }).then(getAppSecret({ store }))\n}\n\nconst checkOAuthToken = async ({ store }) => {\n return new Promise(async (resolve, reject) => {\n if (store.getters.getUserToken()) {\n try {\n await store.dispatch('loginUser', store.getters.getUserToken())\n } catch (e) {\n console.log(e)\n }\n }\n resolve()\n })\n}\n\nconst afterStoreSetup = async ({ store, i18n }) => {\n if (store.state.config.customTheme) {\n // This is a hack to deal with async loading of config.json and themes\n // See: style_setter.js, setPreset()\n window.themeLoaded = true\n store.dispatch('setOption', {\n name: 'customTheme',\n value: store.state.config.customTheme\n })\n }\n\n const width = windowWidth()\n store.dispatch('setMobileLayout', width <= 800)\n\n // Now we can try getting the server settings and logging in\n await Promise.all([\n checkOAuthToken({ store }),\n setConfig({ store }),\n getTOS({ store }),\n getInstancePanel({ store }),\n getStickers({ store }),\n getNodeInfo({ store })\n ])\n\n const router = new VueRouter({\n mode: 'history',\n routes: routes(store),\n scrollBehavior: (to, _from, savedPosition) => {\n if (to.matched.some(m => m.meta.dontScroll)) {\n return false\n }\n return savedPosition || { x: 0, y: 0 }\n }\n })\n\n /* eslint-disable no-new */\n return new Vue({\n router,\n store,\n i18n,\n el: '#app',\n render: h => h(App)\n })\n}\n\nexport default afterStoreSetup\n","import PublicTimeline from 'components/public_timeline/public_timeline.vue'\nimport PublicAndExternalTimeline from 'components/public_and_external_timeline/public_and_external_timeline.vue'\nimport FriendsTimeline from 'components/friends_timeline/friends_timeline.vue'\nimport TagTimeline from 'components/tag_timeline/tag_timeline.vue'\nimport ConversationPage from 'components/conversation-page/conversation-page.vue'\nimport Interactions from 'components/interactions/interactions.vue'\nimport DMs from 'components/dm_timeline/dm_timeline.vue'\nimport UserProfile from 'components/user_profile/user_profile.vue'\nimport Search from 'components/search/search.vue'\nimport Settings from 'components/settings/settings.vue'\nimport Registration from 'components/registration/registration.vue'\nimport PasswordReset from 'components/password_reset/password_reset.vue'\nimport UserSettings from 'components/user_settings/user_settings.vue'\nimport FollowRequests from 'components/follow_requests/follow_requests.vue'\nimport OAuthCallback from 'components/oauth_callback/oauth_callback.vue'\nimport Notifications from 'components/notifications/notifications.vue'\nimport AuthForm from 'components/auth_form/auth_form.js'\nimport ChatPanel from 'components/chat_panel/chat_panel.vue'\nimport WhoToFollow from 'components/who_to_follow/who_to_follow.vue'\nimport About from 'components/about/about.vue'\nimport RemoteUserResolver from 'components/remote_user_resolver/remote_user_resolver.vue'\n\nexport default (store) => {\n const validateAuthenticatedRoute = (to, from, next) => {\n if (store.state.users.currentUser) {\n next()\n } else {\n next(store.state.instance.redirectRootNoLogin || '/main/all')\n }\n }\n\n return [\n { name: 'root',\n path: '/',\n redirect: _to => {\n return (store.state.users.currentUser\n ? store.state.instance.redirectRootLogin\n : store.state.instance.redirectRootNoLogin) || '/main/all'\n }\n },\n { name: 'public-external-timeline', path: '/main/all', component: PublicAndExternalTimeline },\n { name: 'public-timeline', path: '/main/public', component: PublicTimeline },\n { name: 'friends', path: '/main/friends', component: FriendsTimeline, beforeEnter: validateAuthenticatedRoute },\n { name: 'tag-timeline', path: '/tag/:tag', component: TagTimeline },\n { name: 'conversation', path: '/notice/:id', component: ConversationPage, meta: { dontScroll: true } },\n { name: 'remote-user-profile-acct',\n path: '/remote-users/(@?):username([^/@]+)@:hostname([^/@]+)',\n component: RemoteUserResolver,\n beforeEnter: validateAuthenticatedRoute\n },\n { name: 'remote-user-profile',\n path: '/remote-users/:hostname/:username',\n component: RemoteUserResolver,\n beforeEnter: validateAuthenticatedRoute\n },\n { name: 'external-user-profile', path: '/users/:id', component: UserProfile },\n { name: 'interactions', path: '/users/:username/interactions', component: Interactions, beforeEnter: validateAuthenticatedRoute },\n { name: 'dms', path: '/users/:username/dms', component: DMs, beforeEnter: validateAuthenticatedRoute },\n { name: 'settings', path: '/settings', component: Settings },\n { name: 'registration', path: '/registration', component: Registration },\n { name: 'password-reset', path: '/password-reset', component: PasswordReset, props: true },\n { name: 'registration-token', path: '/registration/:token', component: Registration },\n { name: 'friend-requests', path: '/friend-requests', component: FollowRequests, beforeEnter: validateAuthenticatedRoute },\n { name: 'user-settings', path: '/user-settings', component: UserSettings, beforeEnter: validateAuthenticatedRoute },\n { name: 'notifications', path: '/:username/notifications', component: Notifications, beforeEnter: validateAuthenticatedRoute },\n { name: 'login', path: '/login', component: AuthForm },\n { name: 'chat', path: '/chat', component: ChatPanel, props: () => ({ floating: false }) },\n { name: 'oauth-callback', path: '/oauth-callback', component: OAuthCallback, props: (route) => ({ code: route.query.code }) },\n { name: 'search', path: '/search', component: Search, props: (route) => ({ query: route.query.query }) },\n { name: 'who-to-follow', path: '/who-to-follow', component: WhoToFollow, beforeEnter: validateAuthenticatedRoute },\n { name: 'about', path: '/about', component: About },\n { name: 'user-profile', path: '/(users/)?:name', component: UserProfile }\n ]\n}\n","/* script */\nexport * from \"!!babel-loader!./public_timeline.js\"\nimport __vue_script__ from \"!!babel-loader!./public_timeline.js\"/* template */\nimport {render as __vue_render__, staticRenderFns as __vue_static_render_fns__} from \"!!../../../node_modules/vue-loader/lib/template-compiler/index?{\\\"id\\\":\\\"data-v-5f2a502e\\\",\\\"hasScoped\\\":false,\\\"optionsId\\\":\\\"0\\\",\\\"buble\\\":{\\\"transforms\\\":{}}}!../../../node_modules/vue-loader/lib/selector?type=template&index=0!./public_timeline.vue\"\n/* template functional */\nvar __vue_template_functional__ = false\n/* styles */\nvar __vue_styles__ = null\n/* scopeId */\nvar __vue_scopeId__ = null\n/* moduleIdentifier (server only) */\nvar __vue_module_identifier__ = null\nimport normalizeComponent from \"!../../../node_modules/vue-loader/lib/runtime/component-normalizer\"\nvar Component = normalizeComponent(\n __vue_script__,\n __vue_render__,\n __vue_static_render_fns__,\n __vue_template_functional__,\n __vue_styles__,\n __vue_scopeId__,\n __vue_module_identifier__\n)\n\nexport default Component.exports\n","// style-loader: Adds some css to the DOM by adding a + + +
+ <%= render @view_module, @view_template, assigns %> +
+ + diff --git a/lib/pleroma/web/templates/static_fe/static_fe/notice.html.eex b/lib/pleroma/web/templates/static_fe/static_fe/notice.html.eex new file mode 100644 index 000000000..9957697ad --- /dev/null +++ b/lib/pleroma/web/templates/static_fe/static_fe/notice.html.eex @@ -0,0 +1,6 @@ +
+ <%= render("user_card.html", %{user: @user}) %> +
+
<%= @object.data["content"] %>
+
+
diff --git a/lib/pleroma/web/templates/static_fe/static_fe/user_card.html.eex b/lib/pleroma/web/templates/static_fe/static_fe/user_card.html.eex new file mode 100644 index 000000000..8b397c639 --- /dev/null +++ b/lib/pleroma/web/templates/static_fe/static_fe/user_card.html.eex @@ -0,0 +1,11 @@ + From ff8d0902f351f871ab34ae7b127dd3e02e8af4cd Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Sat, 2 Mar 2019 14:23:26 +0000 Subject: [PATCH 096/154] static fe: formatting --- lib/pleroma/web/static_fe/static_fe_controller.ex | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/pleroma/web/static_fe/static_fe_controller.ex b/lib/pleroma/web/static_fe/static_fe_controller.ex index 067af9816..2ac857759 100644 --- a/lib/pleroma/web/static_fe/static_fe_controller.ex +++ b/lib/pleroma/web/static_fe/static_fe_controller.ex @@ -31,7 +31,8 @@ def show_notice(conn, %{"notice_id" => notice_id}) do end end - def show(%{path_info: ["notice", notice_id]} = conn, _params), do: show_notice(conn, %{"notice_id" => notice_id}) + def show(%{path_info: ["notice", notice_id]} = conn, _params), + do: show_notice(conn, %{"notice_id" => notice_id}) # Fallback for unhandled types def show(conn, _params) do From 8f08da750aaa8e04c4a940a566ec831a559a4852 Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Sat, 2 Mar 2019 20:10:30 +0000 Subject: [PATCH 097/154] static fe: use a generic activity representer to render activities --- .../web/static_fe/activity_representer.ex | 52 +++++++++++++++++++ .../web/static_fe/static_fe_controller.ex | 13 ++--- 2 files changed, 55 insertions(+), 10 deletions(-) create mode 100644 lib/pleroma/web/static_fe/activity_representer.ex diff --git a/lib/pleroma/web/static_fe/activity_representer.ex b/lib/pleroma/web/static_fe/activity_representer.ex new file mode 100644 index 000000000..93f8a8813 --- /dev/null +++ b/lib/pleroma/web/static_fe/activity_representer.ex @@ -0,0 +1,52 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2019 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + +defmodule Pleroma.Web.StaticFE.ActivityRepresenter do + alias Pleroma.Activity + alias Pleroma.Object + alias Pleroma.User + alias Pleroma.Web.ActivityPub.Visibility + + def prepare_activity(%User{} = user, %Object{} = object) do + %{} + |> set_user(user) + |> set_object(object) + |> set_title(object) + |> set_content(object) + |> set_attachments(object) + end + + defp set_user(data, %User{} = user), do: Map.put(data, :user, user) + + defp set_object(data, %Object{} = object), do: Map.put(data, :object, object) + + defp set_title(data, %Object{data: %{"name" => name}}) when is_binary(name), + do: Map.put(data, :title, name) + + defp set_title(data, %Object{data: %{"summary" => summary}}) when is_binary(summary), + do: Map.put(data, :title, summary) + + defp set_title(data, _), do: Map.put(data, :title, nil) + + defp set_content(data, %Object{data: %{"content" => content}}) when is_binary(content), + do: Map.put(data, :content, content) + + defp set_content(data, _), do: Map.put(data, :content, nil) + + # TODO: attachments + defp set_attachments(data, _), do: Map.put(data, :attachments, []) + + def represent(activity_id) do + with %Activity{data: %{"type" => "Create"}} = activity <- Activity.get_by_id(activity_id), + true <- Visibility.is_public?(activity), + %Object{} = object <- Object.normalize(activity.data["object"]), + %User{} = user <- User.get_or_fetch(activity.data["actor"]), + data <- prepare_activity(user, object) do + {:ok, data} + else + e -> + {:error, e} + end + end +end diff --git a/lib/pleroma/web/static_fe/static_fe_controller.ex b/lib/pleroma/web/static_fe/static_fe_controller.ex index 2ac857759..7d7cb6ddd 100644 --- a/lib/pleroma/web/static_fe/static_fe_controller.ex +++ b/lib/pleroma/web/static_fe/static_fe_controller.ex @@ -5,24 +5,17 @@ defmodule Pleroma.Web.StaticFE.StaticFEController do use Pleroma.Web, :controller - alias Pleroma.Repo - alias Pleroma.Activity - alias Pleroma.Object - alias Pleroma.User - alias Pleroma.Web.ActivityPub.Visibility + alias Pleroma.Web.StaticFE.ActivityRepresenter require Logger def show_notice(conn, %{"notice_id" => notice_id}) do - with %Activity{} = activity <- Repo.get(Activity, notice_id), - true <- Visibility.is_public?(activity), - %User{} = user <- User.get_or_fetch(activity.data["actor"]), - %Object{} = object <- Object.normalize(activity.data["object"]) do + with {:ok, data} <- ActivityRepresenter.represent(notice_id) do conn |> put_layout(:static_fe) |> put_status(200) |> put_view(Pleroma.Web.StaticFE.StaticFEView) - |> render("notice.html", %{notice: activity, object: object, user: user}) + |> render("notice.html", data) else _ -> conn From 2b5bd5236d793edba54366ec9fed447207a09976 Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Sat, 2 Mar 2019 21:12:38 +0000 Subject: [PATCH 098/154] static fe: add user profile rendering --- .../web/static_fe/activity_representer.ex | 3 ++ .../web/static_fe/static_fe_controller.ex | 24 ++++++++++++- lib/pleroma/web/static_fe/static_fe_view.ex | 2 ++ lib/pleroma/web/static_fe/user_representer.ex | 35 +++++++++++++++++++ .../web/templates/layout/static_fe.html.eex | 4 +++ .../static_fe/static_fe/notice.html.eex | 4 +-- .../static_fe/static_fe/profile.html.eex | 7 ++++ .../static_fe/static_fe/user_card.html.eex | 2 +- 8 files changed, 77 insertions(+), 4 deletions(-) create mode 100644 lib/pleroma/web/static_fe/user_representer.ex create mode 100644 lib/pleroma/web/templates/static_fe/static_fe/profile.html.eex diff --git a/lib/pleroma/web/static_fe/activity_representer.ex b/lib/pleroma/web/static_fe/activity_representer.ex index 93f8a8813..9c4315610 100644 --- a/lib/pleroma/web/static_fe/activity_representer.ex +++ b/lib/pleroma/web/static_fe/activity_representer.ex @@ -17,6 +17,9 @@ def prepare_activity(%User{} = user, %Object{} = object) do |> set_attachments(object) end + def prepare_activity(%User{} = user, %Activity{} = activity), do: + prepare_activity(user, Object.normalize(activity.data["object"])) + defp set_user(data, %User{} = user), do: Map.put(data, :user, user) defp set_object(data, %Object{} = object), do: Map.put(data, :object, object) diff --git a/lib/pleroma/web/static_fe/static_fe_controller.ex b/lib/pleroma/web/static_fe/static_fe_controller.ex index 7d7cb6ddd..78cd325c8 100644 --- a/lib/pleroma/web/static_fe/static_fe_controller.ex +++ b/lib/pleroma/web/static_fe/static_fe_controller.ex @@ -6,6 +6,7 @@ defmodule Pleroma.Web.StaticFE.StaticFEController do use Pleroma.Web, :controller alias Pleroma.Web.StaticFE.ActivityRepresenter + alias Pleroma.Web.StaticFE.UserRepresenter require Logger @@ -15,7 +16,22 @@ def show_notice(conn, %{"notice_id" => notice_id}) do |> put_layout(:static_fe) |> put_status(200) |> put_view(Pleroma.Web.StaticFE.StaticFEView) - |> render("notice.html", data) + |> render("notice.html", %{data: data}) + else + _ -> + conn + |> put_status(404) + |> text("Not found") + end + end + + def show_user(conn, %{"username_or_id" => username_or_id}) do + with {:ok, data} <- UserRepresenter.represent(username_or_id) do + conn + |> put_layout(:static_fe) + |> put_status(200) + |> put_view(Pleroma.Web.StaticFE.StaticFEView) + |> render("profile.html", %{data: data}) else _ -> conn @@ -27,6 +43,12 @@ def show_notice(conn, %{"notice_id" => notice_id}) do def show(%{path_info: ["notice", notice_id]} = conn, _params), do: show_notice(conn, %{"notice_id" => notice_id}) + def show(%{path_info: ["users", user_id]} = conn, _params), + do: show_user(conn, %{"username_or_id" => user_id}) + + def show(%{path_info: [user_id]} = conn, _params), + do: show_user(conn, %{"username_or_id" => user_id}) + # Fallback for unhandled types def show(conn, _params) do conn diff --git a/lib/pleroma/web/static_fe/static_fe_view.ex b/lib/pleroma/web/static_fe/static_fe_view.ex index 7f58e1b2d..71e47d2c1 100644 --- a/lib/pleroma/web/static_fe/static_fe_view.ex +++ b/lib/pleroma/web/static_fe/static_fe_view.ex @@ -9,6 +9,8 @@ defmodule Pleroma.Web.StaticFE.StaticFEView do alias Pleroma.Web.MediaProxy alias Pleroma.Formatter + import Phoenix.HTML + def emoji_for_user(%User{} = user) do (user.info.source_data["tag"] || []) |> Enum.filter(fn %{"type" => t} -> t == "Emoji" end) diff --git a/lib/pleroma/web/static_fe/user_representer.ex b/lib/pleroma/web/static_fe/user_representer.ex new file mode 100644 index 000000000..9d2f1eb85 --- /dev/null +++ b/lib/pleroma/web/static_fe/user_representer.ex @@ -0,0 +1,35 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2019 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + +defmodule Pleroma.Web.StaticFE.UserRepresenter do + alias Pleroma.User + alias Pleroma.Web.ActivityPub.ActivityPub + alias Pleroma.Web.StaticFE.ActivityRepresenter + + def prepare_user(%User{} = user) do + %{} + |> set_user(user) + |> set_timeline(user) + end + + defp set_user(data, %User{} = user), do: Map.put(data, :user, user) + + defp set_timeline(data, %User{} = user) do + activities = + ActivityPub.fetch_user_activities(user, nil, %{}) + |> Enum.map(fn activity -> ActivityRepresenter.prepare_activity(user, activity) end) + + Map.put(data, :timeline, activities) + end + + def represent(username_or_id) do + with %User{} = user <- User.get_cached_by_nickname_or_id(username_or_id), + data <- prepare_user(user) do + {:ok, data} + else + e -> + {:error, e} + end + end +end diff --git a/lib/pleroma/web/templates/layout/static_fe.html.eex b/lib/pleroma/web/templates/layout/static_fe.html.eex index c20958162..40a560460 100644 --- a/lib/pleroma/web/templates/layout/static_fe.html.eex +++ b/lib/pleroma/web/templates/layout/static_fe.html.eex @@ -22,6 +22,10 @@ border-radius: 4px; } + .activity { + margin-bottom: 1em; + } + .avatar { cursor: pointer; } diff --git a/lib/pleroma/web/templates/static_fe/static_fe/notice.html.eex b/lib/pleroma/web/templates/static_fe/static_fe/notice.html.eex index 9957697ad..e8d905d79 100644 --- a/lib/pleroma/web/templates/static_fe/static_fe/notice.html.eex +++ b/lib/pleroma/web/templates/static_fe/static_fe/notice.html.eex @@ -1,6 +1,6 @@
- <%= render("user_card.html", %{user: @user}) %> + <%= render("user_card.html", %{user: @data.user}) %>
-
<%= @object.data["content"] %>
+
<%= raw @data.content %>
diff --git a/lib/pleroma/web/templates/static_fe/static_fe/profile.html.eex b/lib/pleroma/web/templates/static_fe/static_fe/profile.html.eex new file mode 100644 index 000000000..9ae4139ed --- /dev/null +++ b/lib/pleroma/web/templates/static_fe/static_fe/profile.html.eex @@ -0,0 +1,7 @@ +

<%= raw (@data.user.name |> Formatter.emojify(emoji_for_user(@data.user))) %>

+

<%= raw @data.user.bio %>

+
+<%= for activity <- @data.timeline do %> + <%= render("notice.html", %{data: activity}) %> +<% end %> +
diff --git a/lib/pleroma/web/templates/static_fe/static_fe/user_card.html.eex b/lib/pleroma/web/templates/static_fe/static_fe/user_card.html.eex index 8b397c639..c7789f9ac 100644 --- a/lib/pleroma/web/templates/static_fe/static_fe/user_card.html.eex +++ b/lib/pleroma/web/templates/static_fe/static_fe/user_card.html.eex @@ -4,7 +4,7 @@ - <%= @user.name |> Formatter.emojify(emoji_for_user(@user)) %> + <%= raw (@user.name |> Formatter.emojify(emoji_for_user(@user))) %> <%= @user.nickname %> From e2904b5777ecf6c8ffe7fe46f09284bb38b03fc2 Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Sat, 2 Mar 2019 21:40:02 +0000 Subject: [PATCH 099/154] static fe: reformat activity representer --- lib/pleroma/web/static_fe/activity_representer.ex | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pleroma/web/static_fe/activity_representer.ex b/lib/pleroma/web/static_fe/activity_representer.ex index 9c4315610..446c6023e 100644 --- a/lib/pleroma/web/static_fe/activity_representer.ex +++ b/lib/pleroma/web/static_fe/activity_representer.ex @@ -17,8 +17,8 @@ def prepare_activity(%User{} = user, %Object{} = object) do |> set_attachments(object) end - def prepare_activity(%User{} = user, %Activity{} = activity), do: - prepare_activity(user, Object.normalize(activity.data["object"])) + def prepare_activity(%User{} = user, %Activity{} = activity), + do: prepare_activity(user, Object.normalize(activity.data["object"])) defp set_user(data, %User{} = user), do: Map.put(data, :user, user) From b33fbd58e3852fc9de58917fafbb2c575a21dde1 Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Sat, 2 Mar 2019 22:35:54 +0000 Subject: [PATCH 100/154] static fe: add support for message subjects --- .../web/templates/static_fe/static_fe/notice.html.eex | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/pleroma/web/templates/static_fe/static_fe/notice.html.eex b/lib/pleroma/web/templates/static_fe/static_fe/notice.html.eex index e8d905d79..791bd2562 100644 --- a/lib/pleroma/web/templates/static_fe/static_fe/notice.html.eex +++ b/lib/pleroma/web/templates/static_fe/static_fe/notice.html.eex @@ -1,6 +1,13 @@
<%= render("user_card.html", %{user: @data.user}) %>
-
<%= raw @data.content %>
+ <%= if @data.title do %> +
+ <%= raw @data.title %> + <% end %> +
<%= raw @data.content %>
+ <%= if @data.title do %> +
+ <% end %>
From ca5ef201ef8397981acf0647fe5cffea66299bfa Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Sun, 3 Mar 2019 13:36:59 +0000 Subject: [PATCH 101/154] static fe: add remote follow button --- lib/pleroma/web/static_fe/static_fe_view.ex | 1 + lib/pleroma/web/templates/layout/static_fe.html.eex | 9 +++++++++ .../web/templates/static_fe/static_fe/profile.html.eex | 9 ++++++++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/pleroma/web/static_fe/static_fe_view.ex b/lib/pleroma/web/static_fe/static_fe_view.ex index 71e47d2c1..c01e8d40b 100644 --- a/lib/pleroma/web/static_fe/static_fe_view.ex +++ b/lib/pleroma/web/static_fe/static_fe_view.ex @@ -8,6 +8,7 @@ defmodule Pleroma.Web.StaticFE.StaticFEView do alias Pleroma.User alias Pleroma.Web.MediaProxy alias Pleroma.Formatter + alias Pleroma.Web.Router.Helpers import Phoenix.HTML diff --git a/lib/pleroma/web/templates/layout/static_fe.html.eex b/lib/pleroma/web/templates/layout/static_fe.html.eex index 40a560460..7ce9ead90 100644 --- a/lib/pleroma/web/templates/layout/static_fe.html.eex +++ b/lib/pleroma/web/templates/layout/static_fe.html.eex @@ -70,6 +70,15 @@ text-decoration: none; } + .pull-right { + float: right; + } + + .collapse { + margin: 0; + width: auto; + } + h1 { margin: 0; } diff --git a/lib/pleroma/web/templates/static_fe/static_fe/profile.html.eex b/lib/pleroma/web/templates/static_fe/static_fe/profile.html.eex index 9ae4139ed..47b7d5286 100644 --- a/lib/pleroma/web/templates/static_fe/static_fe/profile.html.eex +++ b/lib/pleroma/web/templates/static_fe/static_fe/profile.html.eex @@ -1,4 +1,11 @@ -

<%= raw (@data.user.name |> Formatter.emojify(emoji_for_user(@data.user))) %>

+

+
+ + + +
+ <%= raw (@data.user.name |> Formatter.emojify(emoji_for_user(@data.user))) %> +

<%= raw @data.user.bio %>

<%= for activity <- @data.timeline do %> From d1320160f436c719ecca8b31463dd16a1ab2bdb9 Mon Sep 17 00:00:00 2001 From: Phil Hagelberg Date: Sun, 27 Oct 2019 15:20:43 -0700 Subject: [PATCH 102/154] Looks like source_data is on user directly now. --- lib/pleroma/web/static_fe/static_fe_view.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pleroma/web/static_fe/static_fe_view.ex b/lib/pleroma/web/static_fe/static_fe_view.ex index c01e8d40b..ba67de835 100644 --- a/lib/pleroma/web/static_fe/static_fe_view.ex +++ b/lib/pleroma/web/static_fe/static_fe_view.ex @@ -13,7 +13,7 @@ defmodule Pleroma.Web.StaticFE.StaticFEView do import Phoenix.HTML def emoji_for_user(%User{} = user) do - (user.info.source_data["tag"] || []) + (user.source_data["tag"] || []) |> Enum.filter(fn %{"type" => t} -> t == "Emoji" end) |> Enum.map(fn %{"icon" => %{"url" => url}, "name" => name} -> {String.trim(name, ":"), url} From c1fc1399860c57460cee173ce8ddb980aabf10de Mon Sep 17 00:00:00 2001 From: Phil Hagelberg Date: Sun, 27 Oct 2019 16:37:57 -0700 Subject: [PATCH 103/154] Add permalinks to the static-fe notice rendering. --- lib/pleroma/web/static_fe/activity_representer.ex | 15 ++++++++++++--- .../templates/static_fe/static_fe/notice.html.eex | 6 ++++-- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/lib/pleroma/web/static_fe/activity_representer.ex b/lib/pleroma/web/static_fe/activity_representer.ex index 446c6023e..e383b8415 100644 --- a/lib/pleroma/web/static_fe/activity_representer.ex +++ b/lib/pleroma/web/static_fe/activity_representer.ex @@ -7,18 +7,21 @@ defmodule Pleroma.Web.StaticFE.ActivityRepresenter do alias Pleroma.Object alias Pleroma.User alias Pleroma.Web.ActivityPub.Visibility + alias Pleroma.Web.Router.Helpers - def prepare_activity(%User{} = user, %Object{} = object) do + def prepare_activity(%User{} = user, %Object{} = object, activity_id) do %{} |> set_user(user) |> set_object(object) |> set_title(object) |> set_content(object) + |> set_link(activity_id) + |> set_published(object) |> set_attachments(object) end def prepare_activity(%User{} = user, %Activity{} = activity), - do: prepare_activity(user, Object.normalize(activity.data["object"])) + do: prepare_activity(user, Object.normalize(activity.data["object"]), activity.id) defp set_user(data, %User{} = user), do: Map.put(data, :user, user) @@ -37,6 +40,12 @@ defp set_content(data, %Object{data: %{"content" => content}}) when is_binary(co defp set_content(data, _), do: Map.put(data, :content, nil) + defp set_link(data, activity_id), + do: Map.put(data, :link, Helpers.o_status_url(Pleroma.Web.Endpoint, :notice, activity_id)) + + defp set_published(data, %Object{data: %{"published" => published}}), + do: Map.put(data, :published, published) + # TODO: attachments defp set_attachments(data, _), do: Map.put(data, :attachments, []) @@ -45,7 +54,7 @@ def represent(activity_id) do true <- Visibility.is_public?(activity), %Object{} = object <- Object.normalize(activity.data["object"]), %User{} = user <- User.get_or_fetch(activity.data["actor"]), - data <- prepare_activity(user, object) do + data <- prepare_activity(user, object, activity_id) do {:ok, data} else e -> diff --git a/lib/pleroma/web/templates/static_fe/static_fe/notice.html.eex b/lib/pleroma/web/templates/static_fe/static_fe/notice.html.eex index 791bd2562..d305d9057 100644 --- a/lib/pleroma/web/templates/static_fe/static_fe/notice.html.eex +++ b/lib/pleroma/web/templates/static_fe/static_fe/notice.html.eex @@ -1,13 +1,15 @@
<%= render("user_card.html", %{user: @data.user}) %>
- <%= if @data.title do %> + <%= if @data.title != "" do %>
<%= raw @data.title %> <% end %>
<%= raw @data.content %>
- <%= if @data.title do %> + <%= if @data.title != "" do %>
<% end %> +

+ <%= @data.published %>

From e79d8985ab90bcad33d9ff13c6a16f006c6abac9 Mon Sep 17 00:00:00 2001 From: Phil Hagelberg Date: Sun, 27 Oct 2019 17:53:20 -0700 Subject: [PATCH 104/154] Don't show 404 in static-fe controller unless it's actually not found. --- lib/pleroma/web/static_fe/static_fe_controller.ex | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pleroma/web/static_fe/static_fe_controller.ex b/lib/pleroma/web/static_fe/static_fe_controller.ex index 78cd325c8..8bbd06aa9 100644 --- a/lib/pleroma/web/static_fe/static_fe_controller.ex +++ b/lib/pleroma/web/static_fe/static_fe_controller.ex @@ -18,7 +18,7 @@ def show_notice(conn, %{"notice_id" => notice_id}) do |> put_view(Pleroma.Web.StaticFE.StaticFEView) |> render("notice.html", %{data: data}) else - _ -> + {:error, nil} -> conn |> put_status(404) |> text("Not found") @@ -33,7 +33,7 @@ def show_user(conn, %{"username_or_id" => username_or_id}) do |> put_view(Pleroma.Web.StaticFE.StaticFEView) |> render("profile.html", %{data: data}) else - _ -> + {:error, nil} -> conn |> put_status(404) |> text("Not found") From 0cf04e10880fb0779f34102cacb40950a119d4f8 Mon Sep 17 00:00:00 2001 From: Phil Hagelberg Date: Sun, 27 Oct 2019 19:01:18 -0700 Subject: [PATCH 105/154] Fix OStatus controller to know about StaticFEController. But only when it's configured to be on. --- lib/pleroma/web/ostatus/ostatus_controller.ex | 62 ++++++++++--------- 1 file changed, 33 insertions(+), 29 deletions(-) diff --git a/lib/pleroma/web/ostatus/ostatus_controller.ex b/lib/pleroma/web/ostatus/ostatus_controller.ex index 6958519de..76a244d0f 100644 --- a/lib/pleroma/web/ostatus/ostatus_controller.ex +++ b/lib/pleroma/web/ostatus/ostatus_controller.ex @@ -76,37 +76,41 @@ def activity(%{assigns: %{format: format}} = conn, %{"uuid" => uuid}) do end def notice(%{assigns: %{format: format}} = conn, %{"id" => id}) do - with {_, %Activity{} = activity} <- {:activity, Activity.get_by_id_with_object(id)}, - {_, true} <- {:public?, Visibility.is_public?(activity)}, - %User{} = user <- User.get_cached_by_ap_id(activity.data["actor"]) do - cond do - format == "html" && activity.data["type"] == "Create" -> - %Object{} = object = Object.normalize(activity) - - RedirectController.redirector_with_meta( - conn, - %{ - activity_id: activity.id, - object: object, - url: Router.Helpers.o_status_url(Endpoint, :notice, activity.id), - user: user - } - ) - - format == "html" -> - RedirectController.redirector(conn, nil) - - true -> - represent_activity(conn, format, activity, user) - end + if Pleroma.Config.get([:instance, :static_fe], false) do + Pleroma.Web.StaticFE.StaticFEController.show(conn, %{"notice_id" => id}) else - reason when reason in [{:public?, false}, {:activity, nil}] -> - conn - |> put_status(404) - |> RedirectController.redirector(nil, 404) + with {_, %Activity{} = activity} <- {:activity, Activity.get_by_id_with_object(id)}, + {_, true} <- {:public?, Visibility.is_public?(activity)}, + %User{} = user <- User.get_cached_by_ap_id(activity.data["actor"]) do + cond do + format == "html" && activity.data["type"] == "Create" -> + %Object{} = object = Object.normalize(activity) - e -> - e + RedirectController.redirector_with_meta( + conn, + %{ + activity_id: activity.id, + object: object, + url: Router.Helpers.o_status_url(Endpoint, :notice, activity.id), + user: user + } + ) + + format == "html" -> + RedirectController.redirector(conn, nil) + + true -> + represent_activity(conn, format, activity, user) + end + else + reason when reason in [{:public?, false}, {:activity, nil}] -> + conn + |> put_status(404) + |> RedirectController.redirector(nil, 404) + + e -> + e + end end end From 1d8950798c8aef2cee4458c68d34a72da630ec41 Mon Sep 17 00:00:00 2001 From: Phil Hagelberg Date: Sun, 27 Oct 2019 19:02:19 -0700 Subject: [PATCH 106/154] Fix activity_representer to work with User.get_or_fetch returning tuple. --- lib/pleroma/web/ostatus/ostatus_controller.ex | 2 +- lib/pleroma/web/static_fe/activity_representer.ex | 15 ++++++--------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/lib/pleroma/web/ostatus/ostatus_controller.ex b/lib/pleroma/web/ostatus/ostatus_controller.ex index 76a244d0f..ab5fdbc78 100644 --- a/lib/pleroma/web/ostatus/ostatus_controller.ex +++ b/lib/pleroma/web/ostatus/ostatus_controller.ex @@ -81,7 +81,7 @@ def notice(%{assigns: %{format: format}} = conn, %{"id" => id}) do else with {_, %Activity{} = activity} <- {:activity, Activity.get_by_id_with_object(id)}, {_, true} <- {:public?, Visibility.is_public?(activity)}, - %User{} = user <- User.get_cached_by_ap_id(activity.data["actor"]) do + %User{} = user <- User.get_cached_by_ap_id(activity.data["actor"]) do cond do format == "html" && activity.data["type"] == "Create" -> %Object{} = object = Object.normalize(activity) diff --git a/lib/pleroma/web/static_fe/activity_representer.ex b/lib/pleroma/web/static_fe/activity_representer.ex index e383b8415..9bee732d5 100644 --- a/lib/pleroma/web/static_fe/activity_representer.ex +++ b/lib/pleroma/web/static_fe/activity_representer.ex @@ -9,20 +9,19 @@ defmodule Pleroma.Web.StaticFE.ActivityRepresenter do alias Pleroma.Web.ActivityPub.Visibility alias Pleroma.Web.Router.Helpers - def prepare_activity(%User{} = user, %Object{} = object, activity_id) do + def prepare_activity(%User{} = user, %Activity{} = activity) do + object = Object.normalize(activity.data["object"]) + %{} |> set_user(user) |> set_object(object) |> set_title(object) |> set_content(object) - |> set_link(activity_id) + |> set_link(activity.id) |> set_published(object) |> set_attachments(object) end - def prepare_activity(%User{} = user, %Activity{} = activity), - do: prepare_activity(user, Object.normalize(activity.data["object"]), activity.id) - defp set_user(data, %User{} = user), do: Map.put(data, :user, user) defp set_object(data, %Object{} = object), do: Map.put(data, :object, object) @@ -52,10 +51,8 @@ defp set_attachments(data, _), do: Map.put(data, :attachments, []) def represent(activity_id) do with %Activity{data: %{"type" => "Create"}} = activity <- Activity.get_by_id(activity_id), true <- Visibility.is_public?(activity), - %Object{} = object <- Object.normalize(activity.data["object"]), - %User{} = user <- User.get_or_fetch(activity.data["actor"]), - data <- prepare_activity(user, object, activity_id) do - {:ok, data} + {:ok, %User{} = user} <- User.get_or_fetch(activity.data["actor"]) do + {:ok, prepare_activity(user, activity)} else e -> {:error, e} From 748d800acb56cd1e66adf78e5938623b8da7cde1 Mon Sep 17 00:00:00 2001 From: Phil Hagelberg Date: Mon, 28 Oct 2019 19:05:45 -0700 Subject: [PATCH 107/154] Show images, video, and audio attachments to notices. --- .../web/static_fe/activity_representer.ex | 10 ++++++- lib/pleroma/web/static_fe/static_fe_view.ex | 7 +++++ .../web/templates/layout/static_fe.html.eex | 5 ++++ .../static_fe/static_fe/_attachment.html.eex | 8 ++++++ .../static_fe/static_fe/notice.html.eex | 28 ++++++++++++++----- 5 files changed, 50 insertions(+), 8 deletions(-) create mode 100644 lib/pleroma/web/templates/static_fe/static_fe/_attachment.html.eex diff --git a/lib/pleroma/web/static_fe/activity_representer.ex b/lib/pleroma/web/static_fe/activity_representer.ex index 9bee732d5..7b7e1730c 100644 --- a/lib/pleroma/web/static_fe/activity_representer.ex +++ b/lib/pleroma/web/static_fe/activity_representer.ex @@ -19,6 +19,8 @@ def prepare_activity(%User{} = user, %Activity{} = activity) do |> set_content(object) |> set_link(activity.id) |> set_published(object) + |> set_sensitive(object) + |> set_attachment(object.data["attachment"]) |> set_attachments(object) end @@ -39,17 +41,23 @@ defp set_content(data, %Object{data: %{"content" => content}}) when is_binary(co defp set_content(data, _), do: Map.put(data, :content, nil) + defp set_attachment(data, attachment), do: Map.put(data, :attachment, attachment) + defp set_link(data, activity_id), do: Map.put(data, :link, Helpers.o_status_url(Pleroma.Web.Endpoint, :notice, activity_id)) defp set_published(data, %Object{data: %{"published" => published}}), do: Map.put(data, :published, published) + defp set_sensitive(data, %Object{data: %{"sensitive" => sensitive}}), + do: Map.put(data, :sensitive, sensitive) + # TODO: attachments defp set_attachments(data, _), do: Map.put(data, :attachments, []) def represent(activity_id) do - with %Activity{data: %{"type" => "Create"}} = activity <- Activity.get_by_id(activity_id), + with %Activity{data: %{"type" => "Create"}} = activity <- + Activity.get_by_id_with_object(activity_id), true <- Visibility.is_public?(activity), {:ok, %User{} = user} <- User.get_or_fetch(activity.data["actor"]) do {:ok, prepare_activity(user, activity)} diff --git a/lib/pleroma/web/static_fe/static_fe_view.ex b/lib/pleroma/web/static_fe/static_fe_view.ex index ba67de835..2b3b968d3 100644 --- a/lib/pleroma/web/static_fe/static_fe_view.ex +++ b/lib/pleroma/web/static_fe/static_fe_view.ex @@ -8,10 +8,13 @@ defmodule Pleroma.Web.StaticFE.StaticFEView do alias Pleroma.User alias Pleroma.Web.MediaProxy alias Pleroma.Formatter + alias Pleroma.Web.Metadata.Utils alias Pleroma.Web.Router.Helpers import Phoenix.HTML + @media_types ["image", "audio", "video"] + def emoji_for_user(%User{} = user) do (user.source_data["tag"] || []) |> Enum.filter(fn %{"type" => t} -> t == "Emoji" end) @@ -19,4 +22,8 @@ def emoji_for_user(%User{} = user) do {String.trim(name, ":"), url} end) end + + def fetch_media_type(url) do + Utils.fetch_media_type(@media_types, url["mediaType"]) + end end diff --git a/lib/pleroma/web/templates/layout/static_fe.html.eex b/lib/pleroma/web/templates/layout/static_fe.html.eex index 7ce9ead90..c1fbd89cd 100644 --- a/lib/pleroma/web/templates/layout/static_fe.html.eex +++ b/lib/pleroma/web/templates/layout/static_fe.html.eex @@ -36,6 +36,11 @@ margin-right: 4px; } + .activity-content img, video { + max-width: 800px; + max-height: 800px; + } + a { color: white; } diff --git a/lib/pleroma/web/templates/static_fe/static_fe/_attachment.html.eex b/lib/pleroma/web/templates/static_fe/static_fe/_attachment.html.eex new file mode 100644 index 000000000..7e04e9550 --- /dev/null +++ b/lib/pleroma/web/templates/static_fe/static_fe/_attachment.html.eex @@ -0,0 +1,8 @@ +<%= case @mediaType do %> +<% "audio" -> %> + +<% "video" -> %> + +<% _ -> %> +<%= @name %> +<% end %> diff --git a/lib/pleroma/web/templates/static_fe/static_fe/notice.html.eex b/lib/pleroma/web/templates/static_fe/static_fe/notice.html.eex index d305d9057..9a7824a32 100644 --- a/lib/pleroma/web/templates/static_fe/static_fe/notice.html.eex +++ b/lib/pleroma/web/templates/static_fe/static_fe/notice.html.eex @@ -1,15 +1,29 @@
<%= render("user_card.html", %{user: @data.user}) %> +

+ <%= @data.published %>

<%= if @data.title != "" do %> -
- <%= raw @data.title %> - <% end %> +
+ <%= raw @data.title %> +
<%= raw @data.content %>
+
+ <% else %>
<%= raw @data.content %>
- <%= if @data.title != "" do %> -
<% end %> -

- <%= @data.published %>

+ <%= for %{"name" => name, "url" => [url | _]} <- @data.attachment do %> + <%= if @data.sensitive do %> +
+ sensitive media +
+ <%= render("_attachment.html", %{name: name, url: url["href"], + mediaType: fetch_media_type(url)}) %> +
+
+ <% else %> + <%= render("_attachment.html", %{name: name, url: url["href"], + mediaType: fetch_media_type(url)}) %> + <% end %> + <% end %>
From cc1b07132f1c532c623530ed2375ff7fbdc6d559 Mon Sep 17 00:00:00 2001 From: Phil Hagelberg Date: Mon, 28 Oct 2019 19:47:20 -0700 Subject: [PATCH 108/154] Notices should show entire thread from context. --- lib/pleroma/web/static_fe/static_fe_controller.ex | 12 +++++++++++- lib/pleroma/web/templates/layout/static_fe.html.eex | 5 +++++ .../static_fe/{notice.html.eex => _notice.html.eex} | 4 ++-- .../static_fe/static_fe/conversation.html.eex | 5 +++++ .../templates/static_fe/static_fe/profile.html.eex | 6 +++--- 5 files changed, 26 insertions(+), 6 deletions(-) rename lib/pleroma/web/templates/static_fe/static_fe/{notice.html.eex => _notice.html.eex} (93%) create mode 100644 lib/pleroma/web/templates/static_fe/static_fe/conversation.html.eex diff --git a/lib/pleroma/web/static_fe/static_fe_controller.ex b/lib/pleroma/web/static_fe/static_fe_controller.ex index 8bbd06aa9..d2b55767d 100644 --- a/lib/pleroma/web/static_fe/static_fe_controller.ex +++ b/lib/pleroma/web/static_fe/static_fe_controller.ex @@ -5,6 +5,7 @@ defmodule Pleroma.Web.StaticFE.StaticFEController do use Pleroma.Web, :controller + alias Pleroma.Web.ActivityPub.ActivityPub alias Pleroma.Web.StaticFE.ActivityRepresenter alias Pleroma.Web.StaticFE.UserRepresenter @@ -12,11 +13,20 @@ defmodule Pleroma.Web.StaticFE.StaticFEController do def show_notice(conn, %{"notice_id" => notice_id}) do with {:ok, data} <- ActivityRepresenter.represent(notice_id) do + context = data.object.data["context"] + activities = ActivityPub.fetch_activities_for_context(context, %{}) + + data = + for a <- Enum.reverse(activities) do + ActivityRepresenter.prepare_activity(data.user, a) + |> Map.put(:selected, a.object.id == data.object.id) + end + conn |> put_layout(:static_fe) |> put_status(200) |> put_view(Pleroma.Web.StaticFE.StaticFEView) - |> render("notice.html", %{data: data}) + |> render("conversation.html", %{data: data}) else {:error, nil} -> conn diff --git a/lib/pleroma/web/templates/layout/static_fe.html.eex b/lib/pleroma/web/templates/layout/static_fe.html.eex index c1fbd89cd..9d7ee366a 100644 --- a/lib/pleroma/web/templates/layout/static_fe.html.eex +++ b/lib/pleroma/web/templates/layout/static_fe.html.eex @@ -23,6 +23,7 @@ } .activity { + padding: 1em; margin-bottom: 1em; } @@ -41,6 +42,10 @@ max-height: 800px; } + #selected { + background-color: #1b2735; + } + a { color: white; } diff --git a/lib/pleroma/web/templates/static_fe/static_fe/notice.html.eex b/lib/pleroma/web/templates/static_fe/static_fe/_notice.html.eex similarity index 93% rename from lib/pleroma/web/templates/static_fe/static_fe/notice.html.eex rename to lib/pleroma/web/templates/static_fe/static_fe/_notice.html.eex index 9a7824a32..90b5ef67c 100644 --- a/lib/pleroma/web/templates/static_fe/static_fe/notice.html.eex +++ b/lib/pleroma/web/templates/static_fe/static_fe/_notice.html.eex @@ -1,7 +1,7 @@ -
- <%= render("user_card.html", %{user: @data.user}) %> +
id="selected" <% end %>>

<%= @data.published %>

+ <%= render("user_card.html", %{user: @data.user}) %>
<%= if @data.title != "" do %>
diff --git a/lib/pleroma/web/templates/static_fe/static_fe/conversation.html.eex b/lib/pleroma/web/templates/static_fe/static_fe/conversation.html.eex new file mode 100644 index 000000000..35c3c17cd --- /dev/null +++ b/lib/pleroma/web/templates/static_fe/static_fe/conversation.html.eex @@ -0,0 +1,5 @@ +
+ <%= for notice <- @data do %> + <%= render("_notice.html", %{data: notice}) %> + <% end %> +
diff --git a/lib/pleroma/web/templates/static_fe/static_fe/profile.html.eex b/lib/pleroma/web/templates/static_fe/static_fe/profile.html.eex index 47b7d5286..79bf5a729 100644 --- a/lib/pleroma/web/templates/static_fe/static_fe/profile.html.eex +++ b/lib/pleroma/web/templates/static_fe/static_fe/profile.html.eex @@ -8,7 +8,7 @@

<%= raw @data.user.bio %>

-<%= for activity <- @data.timeline do %> - <%= render("notice.html", %{data: activity}) %> -<% end %> + <%= for activity <- @data.timeline do %> + <%= render("_notice.html", %{data: activity}) %> + <% end %>
From 2d1897e8a739a54a07ab0eae5cf11c260428e532 Mon Sep 17 00:00:00 2001 From: Phil Hagelberg Date: Tue, 29 Oct 2019 17:45:26 -0700 Subject: [PATCH 109/154] Apply all suggested changes from reviewers. --- lib/pleroma/web/ostatus/ostatus_controller.ex | 2 +- .../web/static_fe/activity_representer.ex | 4 +- .../web/static_fe/static_fe_controller.ex | 47 +++++++------------ lib/pleroma/web/static_fe/static_fe_view.ex | 9 ++-- lib/pleroma/web/static_fe/user_representer.ex | 9 ++-- .../static_fe/static_fe/_notice.html.eex | 3 +- 6 files changed, 30 insertions(+), 44 deletions(-) diff --git a/lib/pleroma/web/ostatus/ostatus_controller.ex b/lib/pleroma/web/ostatus/ostatus_controller.ex index ab5fdbc78..be275977e 100644 --- a/lib/pleroma/web/ostatus/ostatus_controller.ex +++ b/lib/pleroma/web/ostatus/ostatus_controller.ex @@ -77,7 +77,7 @@ def activity(%{assigns: %{format: format}} = conn, %{"uuid" => uuid}) do def notice(%{assigns: %{format: format}} = conn, %{"id" => id}) do if Pleroma.Config.get([:instance, :static_fe], false) do - Pleroma.Web.StaticFE.StaticFEController.show(conn, %{"notice_id" => id}) + Pleroma.Web.StaticFE.StaticFEController.call(conn, :show_notice) else with {_, %Activity{} = activity} <- {:activity, Activity.get_by_id_with_object(id)}, {_, true} <- {:public?, Visibility.is_public?(activity)}, diff --git a/lib/pleroma/web/static_fe/activity_representer.ex b/lib/pleroma/web/static_fe/activity_representer.ex index 7b7e1730c..8a499195c 100644 --- a/lib/pleroma/web/static_fe/activity_representer.ex +++ b/lib/pleroma/web/static_fe/activity_representer.ex @@ -62,8 +62,8 @@ def represent(activity_id) do {:ok, %User{} = user} <- User.get_or_fetch(activity.data["actor"]) do {:ok, prepare_activity(user, activity)} else - e -> - {:error, e} + {:error, reason} -> {:error, reason} + _error -> {:error, "Not found"} end end end diff --git a/lib/pleroma/web/static_fe/static_fe_controller.ex b/lib/pleroma/web/static_fe/static_fe_controller.ex index d2b55767d..6e8d0d622 100644 --- a/lib/pleroma/web/static_fe/static_fe_controller.ex +++ b/lib/pleroma/web/static_fe/static_fe_controller.ex @@ -9,9 +9,12 @@ defmodule Pleroma.Web.StaticFE.StaticFEController do alias Pleroma.Web.StaticFE.ActivityRepresenter alias Pleroma.Web.StaticFE.UserRepresenter - require Logger + plug(:put_layout, :static_fe) + plug(:put_view, Pleroma.Web.StaticFE.StaticFEView) + plug(:assign_id) + action_fallback(:not_found) - def show_notice(conn, %{"notice_id" => notice_id}) do + def show_notice(%{assigns: %{notice_id: notice_id}} = conn, _params) do with {:ok, data} <- ActivityRepresenter.represent(notice_id) do context = data.object.data["context"] activities = ActivityPub.fetch_activities_for_context(context, %{}) @@ -22,45 +25,29 @@ def show_notice(conn, %{"notice_id" => notice_id}) do |> Map.put(:selected, a.object.id == data.object.id) end - conn - |> put_layout(:static_fe) - |> put_status(200) - |> put_view(Pleroma.Web.StaticFE.StaticFEView) - |> render("conversation.html", %{data: data}) - else - {:error, nil} -> - conn - |> put_status(404) - |> text("Not found") + render(conn, "conversation.html", data: data) end end - def show_user(conn, %{"username_or_id" => username_or_id}) do + def show_user(%{assigns: %{username_or_id: username_or_id}} = conn, _params) do with {:ok, data} <- UserRepresenter.represent(username_or_id) do - conn - |> put_layout(:static_fe) - |> put_status(200) - |> put_view(Pleroma.Web.StaticFE.StaticFEView) - |> render("profile.html", %{data: data}) - else - {:error, nil} -> - conn - |> put_status(404) - |> text("Not found") + render(conn, "profile.html", data: data) end end - def show(%{path_info: ["notice", notice_id]} = conn, _params), - do: show_notice(conn, %{"notice_id" => notice_id}) + def assign_id(%{path_info: ["notice", notice_id]} = conn, _opts), + do: assign(conn, :notice_id, notice_id) - def show(%{path_info: ["users", user_id]} = conn, _params), - do: show_user(conn, %{"username_or_id" => user_id}) + def assign_id(%{path_info: ["users", user_id]} = conn, _opts), + do: assign(conn, :username_or_id, user_id) - def show(%{path_info: [user_id]} = conn, _params), - do: show_user(conn, %{"username_or_id" => user_id}) + def assign_id(%{path_info: [user_id]} = conn, _opts), + do: assign(conn, :username_or_id, user_id) + + def assign_id(conn, _opts), do: conn # Fallback for unhandled types - def show(conn, _params) do + def not_found(conn, _opts) do conn |> put_status(404) |> text("Not found") diff --git a/lib/pleroma/web/static_fe/static_fe_view.ex b/lib/pleroma/web/static_fe/static_fe_view.ex index 2b3b968d3..d633751dd 100644 --- a/lib/pleroma/web/static_fe/static_fe_view.ex +++ b/lib/pleroma/web/static_fe/static_fe_view.ex @@ -11,19 +11,20 @@ defmodule Pleroma.Web.StaticFE.StaticFEView do alias Pleroma.Web.Metadata.Utils alias Pleroma.Web.Router.Helpers - import Phoenix.HTML + use Phoenix.HTML @media_types ["image", "audio", "video"] def emoji_for_user(%User{} = user) do - (user.source_data["tag"] || []) + user.source_data + |> Map.get("tag", []) |> Enum.filter(fn %{"type" => t} -> t == "Emoji" end) |> Enum.map(fn %{"icon" => %{"url" => url}, "name" => name} -> {String.trim(name, ":"), url} end) end - def fetch_media_type(url) do - Utils.fetch_media_type(@media_types, url["mediaType"]) + def fetch_media_type(%{"mediaType" => mediaType}) do + Utils.fetch_media_type(@media_types, mediaType) end end diff --git a/lib/pleroma/web/static_fe/user_representer.ex b/lib/pleroma/web/static_fe/user_representer.ex index 9d2f1eb85..26320ea69 100644 --- a/lib/pleroma/web/static_fe/user_representer.ex +++ b/lib/pleroma/web/static_fe/user_representer.ex @@ -24,12 +24,9 @@ defp set_timeline(data, %User{} = user) do end def represent(username_or_id) do - with %User{} = user <- User.get_cached_by_nickname_or_id(username_or_id), - data <- prepare_user(user) do - {:ok, data} - else - e -> - {:error, e} + case User.get_cached_by_nickname_or_id(username_or_id) do + %User{} = user -> {:ok, prepare_user(user)} + nil -> {:error, "User not found"} end end end diff --git a/lib/pleroma/web/templates/static_fe/static_fe/_notice.html.eex b/lib/pleroma/web/templates/static_fe/static_fe/_notice.html.eex index 90b5ef67c..ed43ae838 100644 --- a/lib/pleroma/web/templates/static_fe/static_fe/_notice.html.eex +++ b/lib/pleroma/web/templates/static_fe/static_fe/_notice.html.eex @@ -1,6 +1,7 @@
id="selected" <% end %>>

- <%= @data.published %>

+ <%= link @data.published, to: @data.link, class: "activity-link" %> +

<%= render("user_card.html", %{user: @data.user}) %>
<%= if @data.title != "" do %> From e944a2213dd5eaaf69b9e8d8f5e035dbba2fdab1 Mon Sep 17 00:00:00 2001 From: Phil Hagelberg Date: Tue, 29 Oct 2019 17:53:58 -0700 Subject: [PATCH 110/154] Use gettext for sensitive media warning. --- lib/pleroma/web/static_fe/static_fe_view.ex | 1 + lib/pleroma/web/templates/static_fe/static_fe/_notice.html.eex | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/pleroma/web/static_fe/static_fe_view.ex b/lib/pleroma/web/static_fe/static_fe_view.ex index d633751dd..1194b7ecc 100644 --- a/lib/pleroma/web/static_fe/static_fe_view.ex +++ b/lib/pleroma/web/static_fe/static_fe_view.ex @@ -6,6 +6,7 @@ defmodule Pleroma.Web.StaticFE.StaticFEView do use Pleroma.Web, :view alias Pleroma.User + alias Pleroma.Web.Gettext alias Pleroma.Web.MediaProxy alias Pleroma.Formatter alias Pleroma.Web.Metadata.Utils diff --git a/lib/pleroma/web/templates/static_fe/static_fe/_notice.html.eex b/lib/pleroma/web/templates/static_fe/static_fe/_notice.html.eex index ed43ae838..c4cdb1029 100644 --- a/lib/pleroma/web/templates/static_fe/static_fe/_notice.html.eex +++ b/lib/pleroma/web/templates/static_fe/static_fe/_notice.html.eex @@ -15,7 +15,7 @@ <%= for %{"name" => name, "url" => [url | _]} <- @data.attachment do %> <%= if @data.sensitive do %>
- sensitive media + <%= Gettext.gettext("sensitive media") %>
<%= render("_attachment.html", %{name: name, url: url["href"], mediaType: fetch_media_type(url)}) %> From 41fde63defd332a84b6c4d4ca78848e623a9d122 Mon Sep 17 00:00:00 2001 From: Phil Hagelberg Date: Tue, 29 Oct 2019 19:27:42 -0700 Subject: [PATCH 111/154] Get rid of @data in views and use separate fields. --- .../web/static_fe/static_fe_controller.ex | 12 +++++------- .../static_fe/static_fe/_notice.html.eex | 18 +++++++++--------- .../static_fe/static_fe/conversation.html.eex | 4 ++-- .../static_fe/static_fe/profile.html.eex | 10 +++++----- 4 files changed, 21 insertions(+), 23 deletions(-) diff --git a/lib/pleroma/web/static_fe/static_fe_controller.ex b/lib/pleroma/web/static_fe/static_fe_controller.ex index 6e8d0d622..c77df8e7d 100644 --- a/lib/pleroma/web/static_fe/static_fe_controller.ex +++ b/lib/pleroma/web/static_fe/static_fe_controller.ex @@ -17,22 +17,20 @@ defmodule Pleroma.Web.StaticFE.StaticFEController do def show_notice(%{assigns: %{notice_id: notice_id}} = conn, _params) do with {:ok, data} <- ActivityRepresenter.represent(notice_id) do context = data.object.data["context"] - activities = ActivityPub.fetch_activities_for_context(context, %{}) - data = - for a <- Enum.reverse(activities) do + activities = + for a <- Enum.reverse(ActivityPub.fetch_activities_for_context(context, %{})) do ActivityRepresenter.prepare_activity(data.user, a) |> Map.put(:selected, a.object.id == data.object.id) end - render(conn, "conversation.html", data: data) + render(conn, "conversation.html", activities: activities) end end def show_user(%{assigns: %{username_or_id: username_or_id}} = conn, _params) do - with {:ok, data} <- UserRepresenter.represent(username_or_id) do - render(conn, "profile.html", data: data) - end + {:ok, data} = UserRepresenter.represent(username_or_id) + render(conn, "profile.html", %{user: data.user, timeline: data.timeline}) end def assign_id(%{path_info: ["notice", notice_id]} = conn, _opts), diff --git a/lib/pleroma/web/templates/static_fe/static_fe/_notice.html.eex b/lib/pleroma/web/templates/static_fe/static_fe/_notice.html.eex index c4cdb1029..b16d19a2c 100644 --- a/lib/pleroma/web/templates/static_fe/static_fe/_notice.html.eex +++ b/lib/pleroma/web/templates/static_fe/static_fe/_notice.html.eex @@ -1,19 +1,19 @@ -
id="selected" <% end %>> +
id="selected" <% end %>>

- <%= link @data.published, to: @data.link, class: "activity-link" %> + <%= link @published, to: @link, class: "activity-link" %>

- <%= render("user_card.html", %{user: @data.user}) %> + <%= render("user_card.html", %{user: @user}) %>
- <%= if @data.title != "" do %> + <%= if @title != "" do %>
- <%= raw @data.title %> -
<%= raw @data.content %>
+ <%= raw @title %> +
<%= raw @content %>
<% else %> -
<%= raw @data.content %>
+
<%= raw @content %>
<% end %> - <%= for %{"name" => name, "url" => [url | _]} <- @data.attachment do %> - <%= if @data.sensitive do %> + <%= for %{"name" => name, "url" => [url | _]} <- @attachment do %> + <%= if @sensitive do %>
<%= Gettext.gettext("sensitive media") %>
diff --git a/lib/pleroma/web/templates/static_fe/static_fe/conversation.html.eex b/lib/pleroma/web/templates/static_fe/static_fe/conversation.html.eex index 35c3c17cd..f0d3b5972 100644 --- a/lib/pleroma/web/templates/static_fe/static_fe/conversation.html.eex +++ b/lib/pleroma/web/templates/static_fe/static_fe/conversation.html.eex @@ -1,5 +1,5 @@
- <%= for notice <- @data do %> - <%= render("_notice.html", %{data: notice}) %> + <%= for activity <- @activities do %> + <%= render("_notice.html", activity) %> <% end %>
diff --git a/lib/pleroma/web/templates/static_fe/static_fe/profile.html.eex b/lib/pleroma/web/templates/static_fe/static_fe/profile.html.eex index 79bf5a729..da23be1e5 100644 --- a/lib/pleroma/web/templates/static_fe/static_fe/profile.html.eex +++ b/lib/pleroma/web/templates/static_fe/static_fe/profile.html.eex @@ -1,14 +1,14 @@

- +
- <%= raw (@data.user.name |> Formatter.emojify(emoji_for_user(@data.user))) %> + <%= raw (@user.name |> Formatter.emojify(emoji_for_user(@user))) %>

-

<%= raw @data.user.bio %>

+

<%= raw @user.bio %>

- <%= for activity <- @data.timeline do %> - <%= render("_notice.html", %{data: activity}) %> + <%= for activity <- @timeline do %> + <%= render("_notice.html", Map.put(activity, :selected, false)) %> <% end %>
From 33a26b61c30ad8084003f0f1c646bc997a8d88ac Mon Sep 17 00:00:00 2001 From: Phil Hagelberg Date: Tue, 29 Oct 2019 20:30:43 -0700 Subject: [PATCH 112/154] Remove activity/user representer; move logic to controller. --- .../web/static_fe/activity_representer.ex | 69 ------------------- .../web/static_fe/static_fe_controller.ex | 59 ++++++++++++---- lib/pleroma/web/static_fe/user_representer.ex | 32 --------- 3 files changed, 46 insertions(+), 114 deletions(-) delete mode 100644 lib/pleroma/web/static_fe/activity_representer.ex delete mode 100644 lib/pleroma/web/static_fe/user_representer.ex diff --git a/lib/pleroma/web/static_fe/activity_representer.ex b/lib/pleroma/web/static_fe/activity_representer.ex deleted file mode 100644 index 8a499195c..000000000 --- a/lib/pleroma/web/static_fe/activity_representer.ex +++ /dev/null @@ -1,69 +0,0 @@ -# Pleroma: A lightweight social networking server -# Copyright © 2017-2019 Pleroma Authors -# SPDX-License-Identifier: AGPL-3.0-only - -defmodule Pleroma.Web.StaticFE.ActivityRepresenter do - alias Pleroma.Activity - alias Pleroma.Object - alias Pleroma.User - alias Pleroma.Web.ActivityPub.Visibility - alias Pleroma.Web.Router.Helpers - - def prepare_activity(%User{} = user, %Activity{} = activity) do - object = Object.normalize(activity.data["object"]) - - %{} - |> set_user(user) - |> set_object(object) - |> set_title(object) - |> set_content(object) - |> set_link(activity.id) - |> set_published(object) - |> set_sensitive(object) - |> set_attachment(object.data["attachment"]) - |> set_attachments(object) - end - - defp set_user(data, %User{} = user), do: Map.put(data, :user, user) - - defp set_object(data, %Object{} = object), do: Map.put(data, :object, object) - - defp set_title(data, %Object{data: %{"name" => name}}) when is_binary(name), - do: Map.put(data, :title, name) - - defp set_title(data, %Object{data: %{"summary" => summary}}) when is_binary(summary), - do: Map.put(data, :title, summary) - - defp set_title(data, _), do: Map.put(data, :title, nil) - - defp set_content(data, %Object{data: %{"content" => content}}) when is_binary(content), - do: Map.put(data, :content, content) - - defp set_content(data, _), do: Map.put(data, :content, nil) - - defp set_attachment(data, attachment), do: Map.put(data, :attachment, attachment) - - defp set_link(data, activity_id), - do: Map.put(data, :link, Helpers.o_status_url(Pleroma.Web.Endpoint, :notice, activity_id)) - - defp set_published(data, %Object{data: %{"published" => published}}), - do: Map.put(data, :published, published) - - defp set_sensitive(data, %Object{data: %{"sensitive" => sensitive}}), - do: Map.put(data, :sensitive, sensitive) - - # TODO: attachments - defp set_attachments(data, _), do: Map.put(data, :attachments, []) - - def represent(activity_id) do - with %Activity{data: %{"type" => "Create"}} = activity <- - Activity.get_by_id_with_object(activity_id), - true <- Visibility.is_public?(activity), - {:ok, %User{} = user} <- User.get_or_fetch(activity.data["actor"]) do - {:ok, prepare_activity(user, activity)} - else - {:error, reason} -> {:error, reason} - _error -> {:error, "Not found"} - end - end -end diff --git a/lib/pleroma/web/static_fe/static_fe_controller.ex b/lib/pleroma/web/static_fe/static_fe_controller.ex index c77df8e7d..a5cb76167 100644 --- a/lib/pleroma/web/static_fe/static_fe_controller.ex +++ b/lib/pleroma/web/static_fe/static_fe_controller.ex @@ -5,32 +5,65 @@ defmodule Pleroma.Web.StaticFE.StaticFEController do use Pleroma.Web, :controller + alias Pleroma.Activity + alias Pleroma.Object + alias Pleroma.User alias Pleroma.Web.ActivityPub.ActivityPub - alias Pleroma.Web.StaticFE.ActivityRepresenter - alias Pleroma.Web.StaticFE.UserRepresenter + alias Pleroma.Web.Router.Helpers plug(:put_layout, :static_fe) plug(:put_view, Pleroma.Web.StaticFE.StaticFEView) plug(:assign_id) action_fallback(:not_found) + defp get_title(%Object{data: %{"name" => name}}) when is_binary(name), + do: name + + defp get_title(%Object{data: %{"summary" => summary}}) when is_binary(summary), + do: summary + + defp get_title(_), do: nil + + def represent(%Activity{} = activity, %User{} = user, selected) do + %{ + user: user, + title: get_title(activity.object), + content: activity.object.data["content"] || nil, + attachment: activity.object.data["attachment"], + link: Helpers.o_status_url(Pleroma.Web.Endpoint, :notice, activity.id), + published: activity.object.data["published"], + sensitive: activity.object.data["sensitive"], + selected: selected + } + end + + def represent(%Activity{} = activity, selected) do + {:ok, user} = User.get_or_fetch(activity.data["actor"]) + represent(activity, user, selected) + end + def show_notice(%{assigns: %{notice_id: notice_id}} = conn, _params) do - with {:ok, data} <- ActivityRepresenter.represent(notice_id) do - context = data.object.data["context"] + activity = Activity.get_by_id_with_object(notice_id) + context = activity.object.data["context"] + activities = ActivityPub.fetch_activities_for_context(context, %{}) - activities = - for a <- Enum.reverse(ActivityPub.fetch_activities_for_context(context, %{})) do - ActivityRepresenter.prepare_activity(data.user, a) - |> Map.put(:selected, a.object.id == data.object.id) - end + represented = + for a <- Enum.reverse(activities) do + represent(activity, a.object.id == activity.object.id) + end - render(conn, "conversation.html", activities: activities) - end + render(conn, "conversation.html", activities: represented) end def show_user(%{assigns: %{username_or_id: username_or_id}} = conn, _params) do - {:ok, data} = UserRepresenter.represent(username_or_id) - render(conn, "profile.html", %{user: data.user, timeline: data.timeline}) + %User{} = user = User.get_cached_by_nickname_or_id(username_or_id) + + timeline = + for activity <- ActivityPub.fetch_user_activities(user, nil, %{}) do + represent(activity, user, false) + end + + render(conn, "profile.html", %{user: user, timeline: timeline}) end def assign_id(%{path_info: ["notice", notice_id]} = conn, _opts), diff --git a/lib/pleroma/web/static_fe/user_representer.ex b/lib/pleroma/web/static_fe/user_representer.ex deleted file mode 100644 index 26320ea69..000000000 --- a/lib/pleroma/web/static_fe/user_representer.ex +++ /dev/null @@ -1,32 +0,0 @@ -# Pleroma: A lightweight social networking server -# Copyright © 2017-2019 Pleroma Authors -# SPDX-License-Identifier: AGPL-3.0-only - -defmodule Pleroma.Web.StaticFE.UserRepresenter do - alias Pleroma.User - alias Pleroma.Web.ActivityPub.ActivityPub - alias Pleroma.Web.StaticFE.ActivityRepresenter - - def prepare_user(%User{} = user) do - %{} - |> set_user(user) - |> set_timeline(user) - end - - defp set_user(data, %User{} = user), do: Map.put(data, :user, user) - - defp set_timeline(data, %User{} = user) do - activities = - ActivityPub.fetch_user_activities(user, nil, %{}) - |> Enum.map(fn activity -> ActivityRepresenter.prepare_activity(user, activity) end) - - Map.put(data, :timeline, activities) - end - - def represent(username_or_id) do - case User.get_cached_by_nickname_or_id(username_or_id) do - %User{} = user -> {:ok, prepare_user(user)} - nil -> {:error, "User not found"} - end - end -end From 918e1353f6bc7f6dfe317a87d942dfa2e53064af Mon Sep 17 00:00:00 2001 From: Phil Hagelberg Date: Tue, 29 Oct 2019 20:55:43 -0700 Subject: [PATCH 113/154] Add header to profile/notice pages linking to pleroma-fe. --- lib/pleroma/web/static_fe/static_fe_controller.ex | 6 ++++-- .../web/templates/static_fe/static_fe/_notice.html.eex | 2 +- .../static_fe/{user_card.html.eex => _user_card.html.eex} | 0 .../web/templates/static_fe/static_fe/conversation.html.eex | 2 ++ .../web/templates/static_fe/static_fe/profile.html.eex | 6 ++++-- 5 files changed, 11 insertions(+), 5 deletions(-) rename lib/pleroma/web/templates/static_fe/static_fe/{user_card.html.eex => _user_card.html.eex} (100%) diff --git a/lib/pleroma/web/static_fe/static_fe_controller.ex b/lib/pleroma/web/static_fe/static_fe_controller.ex index a5cb76167..fe2fb09c4 100644 --- a/lib/pleroma/web/static_fe/static_fe_controller.ex +++ b/lib/pleroma/web/static_fe/static_fe_controller.ex @@ -43,6 +43,7 @@ def represent(%Activity{} = activity, selected) do end def show_notice(%{assigns: %{notice_id: notice_id}} = conn, _params) do + instance_name = Pleroma.Config.get([:instance, :name], "Pleroma") activity = Activity.get_by_id_with_object(notice_id) context = activity.object.data["context"] activities = ActivityPub.fetch_activities_for_context(context, %{}) @@ -52,10 +53,11 @@ def show_notice(%{assigns: %{notice_id: notice_id}} = conn, _params) do represent(activity, a.object.id == activity.object.id) end - render(conn, "conversation.html", activities: represented) + render(conn, "conversation.html", %{activities: represented, instance_name: instance_name}) end def show_user(%{assigns: %{username_or_id: username_or_id}} = conn, _params) do + instance_name = Pleroma.Config.get([:instance, :name], "Pleroma") %User{} = user = User.get_cached_by_nickname_or_id(username_or_id) timeline = @@ -63,7 +65,7 @@ def show_user(%{assigns: %{username_or_id: username_or_id}} = conn, _params) do represent(activity, user, false) end - render(conn, "profile.html", %{user: user, timeline: timeline}) + render(conn, "profile.html", %{user: user, timeline: timeline, instance_name: instance_name}) end def assign_id(%{path_info: ["notice", notice_id]} = conn, _opts), diff --git a/lib/pleroma/web/templates/static_fe/static_fe/_notice.html.eex b/lib/pleroma/web/templates/static_fe/static_fe/_notice.html.eex index b16d19a2c..d1daa281c 100644 --- a/lib/pleroma/web/templates/static_fe/static_fe/_notice.html.eex +++ b/lib/pleroma/web/templates/static_fe/static_fe/_notice.html.eex @@ -2,7 +2,7 @@

<%= link @published, to: @link, class: "activity-link" %>

- <%= render("user_card.html", %{user: @user}) %> + <%= render("_user_card.html", %{user: @user}) %>
<%= if @title != "" do %>
diff --git a/lib/pleroma/web/templates/static_fe/static_fe/user_card.html.eex b/lib/pleroma/web/templates/static_fe/static_fe/_user_card.html.eex similarity index 100% rename from lib/pleroma/web/templates/static_fe/static_fe/user_card.html.eex rename to lib/pleroma/web/templates/static_fe/static_fe/_user_card.html.eex diff --git a/lib/pleroma/web/templates/static_fe/static_fe/conversation.html.eex b/lib/pleroma/web/templates/static_fe/static_fe/conversation.html.eex index f0d3b5972..3a1249df2 100644 --- a/lib/pleroma/web/templates/static_fe/static_fe/conversation.html.eex +++ b/lib/pleroma/web/templates/static_fe/static_fe/conversation.html.eex @@ -1,3 +1,5 @@ +

<%= link @instance_name, to: "/" %>

+
<%= for activity <- @activities do %> <%= render("_notice.html", activity) %> diff --git a/lib/pleroma/web/templates/static_fe/static_fe/profile.html.eex b/lib/pleroma/web/templates/static_fe/static_fe/profile.html.eex index da23be1e5..8f2c74627 100644 --- a/lib/pleroma/web/templates/static_fe/static_fe/profile.html.eex +++ b/lib/pleroma/web/templates/static_fe/static_fe/profile.html.eex @@ -1,11 +1,13 @@ -

+

<%= link @instance_name, to: "/" %>

+ +

<%= raw (@user.name |> Formatter.emojify(emoji_for_user(@user))) %> -

+

<%= raw @user.bio %>

<%= for activity <- @timeline do %> From 93e9c0cedf0e2b4ab5966832cc912369c7aaf3ad Mon Sep 17 00:00:00 2001 From: Phil Hagelberg Date: Tue, 29 Oct 2019 21:09:05 -0700 Subject: [PATCH 114/154] Format dates using CommonAPI utils. --- lib/pleroma/web/static_fe/static_fe_view.ex | 5 +++++ .../web/templates/static_fe/static_fe/_notice.html.eex | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/pleroma/web/static_fe/static_fe_view.ex b/lib/pleroma/web/static_fe/static_fe_view.ex index 1194b7ecc..c19aa07e1 100644 --- a/lib/pleroma/web/static_fe/static_fe_view.ex +++ b/lib/pleroma/web/static_fe/static_fe_view.ex @@ -28,4 +28,9 @@ def emoji_for_user(%User{} = user) do def fetch_media_type(%{"mediaType" => mediaType}) do Utils.fetch_media_type(@media_types, mediaType) end + + def format_date(date) do + {:ok, date, _} = DateTime.from_iso8601(date) + Pleroma.Web.CommonAPI.Utils.format_asctime(date) + end end diff --git a/lib/pleroma/web/templates/static_fe/static_fe/_notice.html.eex b/lib/pleroma/web/templates/static_fe/static_fe/_notice.html.eex index d1daa281c..9841fcf84 100644 --- a/lib/pleroma/web/templates/static_fe/static_fe/_notice.html.eex +++ b/lib/pleroma/web/templates/static_fe/static_fe/_notice.html.eex @@ -1,6 +1,6 @@
id="selected" <% end %>>

- <%= link @published, to: @link, class: "activity-link" %> + <%= link format_date(@published), to: @link, class: "activity-link" %>

<%= render("_user_card.html", %{user: @user}) %>
From e4b9784c3938772edf45340107a34a58aeeea690 Mon Sep 17 00:00:00 2001 From: Phil Hagelberg Date: Tue, 29 Oct 2019 22:05:18 -0700 Subject: [PATCH 115/154] Show counts for replies, likes, and announces for selected notice. Using text instead of an icon, for now. --- lib/pleroma/web/static_fe/static_fe_controller.ex | 15 +++++++++++++-- .../web/templates/layout/static_fe.html.eex | 6 ++++++ .../static_fe/static_fe/_notice.html.eex | 7 +++++++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/lib/pleroma/web/static_fe/static_fe_controller.ex b/lib/pleroma/web/static_fe/static_fe_controller.ex index fe2fb09c4..d2e72b476 100644 --- a/lib/pleroma/web/static_fe/static_fe_controller.ex +++ b/lib/pleroma/web/static_fe/static_fe_controller.ex @@ -24,6 +24,16 @@ defp get_title(%Object{data: %{"summary" => summary}}) when is_binary(summary), defp get_title(_), do: nil + def get_counts(%Activity{} = activity) do + %Object{data: data} = Object.normalize(activity) + + %{ + likes: data["like_count"] || 0, + replies: data["repliesCount"] || 0, + announces: data["announcement_count"] || 0 + } + end + def represent(%Activity{} = activity, %User{} = user, selected) do %{ user: user, @@ -33,7 +43,8 @@ def represent(%Activity{} = activity, %User{} = user, selected) do link: Helpers.o_status_url(Pleroma.Web.Endpoint, :notice, activity.id), published: activity.object.data["published"], sensitive: activity.object.data["sensitive"], - selected: selected + selected: selected, + counts: get_counts(activity) } end @@ -50,7 +61,7 @@ def show_notice(%{assigns: %{notice_id: notice_id}} = conn, _params) do represented = for a <- Enum.reverse(activities) do - represent(activity, a.object.id == activity.object.id) + represent(a, a.object.id == activity.object.id) end render(conn, "conversation.html", %{activities: represented, instance_name: instance_name}) diff --git a/lib/pleroma/web/templates/layout/static_fe.html.eex b/lib/pleroma/web/templates/layout/static_fe.html.eex index 9d7ee366a..e42047de9 100644 --- a/lib/pleroma/web/templates/layout/static_fe.html.eex +++ b/lib/pleroma/web/templates/layout/static_fe.html.eex @@ -24,6 +24,7 @@ .activity { padding: 1em; + padding-bottom: 2em; margin-bottom: 1em; } @@ -46,6 +47,11 @@ background-color: #1b2735; } + .counts dt, .counts dd { + float: left; + margin-left: 1em; + } + a { color: white; } diff --git a/lib/pleroma/web/templates/static_fe/static_fe/_notice.html.eex b/lib/pleroma/web/templates/static_fe/static_fe/_notice.html.eex index 9841fcf84..2a46dadb4 100644 --- a/lib/pleroma/web/templates/static_fe/static_fe/_notice.html.eex +++ b/lib/pleroma/web/templates/static_fe/static_fe/_notice.html.eex @@ -27,4 +27,11 @@ <% end %> <% end %>
+ <%= if @selected do %> +
+
<%= Gettext.gettext("replies") %>
<%= @counts.replies %>
+
<%= Gettext.gettext("announces") %>
<%= @counts.announces %>
+
<%= Gettext.gettext("likes") %>
<%= @counts.likes %>
+
+ <% end %>
From 1dc785b74be6dc790d2b24e833642060303ecee2 Mon Sep 17 00:00:00 2001 From: Phil Hagelberg Date: Wed, 30 Oct 2019 20:20:26 -0700 Subject: [PATCH 116/154] Move static-fe CSS to a separate file. --- .../web/templates/layout/static_fe.html.eex | 165 +---------------- priv/static/static/static-fe.css | 172 ++++++++++++++++++ 2 files changed, 173 insertions(+), 164 deletions(-) create mode 100644 priv/static/static/static-fe.css diff --git a/lib/pleroma/web/templates/layout/static_fe.html.eex b/lib/pleroma/web/templates/layout/static_fe.html.eex index e42047de9..62b59f17c 100644 --- a/lib/pleroma/web/templates/layout/static_fe.html.eex +++ b/lib/pleroma/web/templates/layout/static_fe.html.eex @@ -6,170 +6,7 @@ <%= Application.get_env(:pleroma, :instance)[:name] %> - +
diff --git a/priv/static/static/static-fe.css b/priv/static/static/static-fe.css new file mode 100644 index 000000000..d6bb58c33 --- /dev/null +++ b/priv/static/static/static-fe.css @@ -0,0 +1,172 @@ +body { + background-color: #282c37; + font-family: sans-serif; + color: white; +} + +.container { + margin: 50px auto; + max-width: 960px; + padding: 40px; + background-color: #313543; + border-radius: 4px; +} + +header { + border-bottom: 2em solid #282c37; +} + +.activity { + border-radius: 4px; + padding: 1em; + padding-bottom: 2em; + margin-bottom: 1em; +} + +.avatar { + cursor: pointer; +} + +.avatar img { + float: left; + border-radius: 4px; + margin-right: 4px; +} + +.activity-content img, video, audio { + padding: 1em; + max-width: 800px; + max-height: 800px; +} + +#selected { + background-color: #1b2735; +} + +.counts dt, .counts dd { + float: left; + margin-left: 1em; +} + +a { + color: white; +} + +.h-card { + min-height: 48px; + margin-bottom: 8px; +} + +.h-card a { + text-decoration: none; +} + +.h-card a:hover { + text-decoration: underline; +} + +.display-name { + padding-top: 4px; + display: block; + text-overflow: ellipsis; + overflow: hidden; + color: white; +} + +/* keep emoji from being hilariously huge */ +.display-name img { + max-height: 1em; +} + +.display-name .nickname { + padding-top: 4px; + display: block; +} + +.nickname:hover { + text-decoration: none; +} + +.pull-right { + float: right; +} + +.collapse { + margin: 0; + width: auto; +} + +h1 { + margin: 0; +} + +h2 { + color: #9baec8; + font-weight: normal; + font-size: 20px; + margin-bottom: 40px; +} + +form { + width: 100%; +} + +input { + box-sizing: border-box; + width: 100%; + padding: 10px; + margin-top: 20px; + background-color: rgba(0,0,0,.1); + color: white; + border: 0; + border-bottom: 2px solid #9baec8; + font-size: 14px; +} + +input:focus { + border-bottom: 2px solid #4b8ed8; +} + +input[type="checkbox"] { + width: auto; +} + +button { + box-sizing: border-box; + width: 100%; + color: white; + background-color: #419bdd; + border-radius: 4px; + border: none; + padding: 10px; + margin-top: 30px; + text-transform: uppercase; + font-weight: 500; + font-size: 16px; +} + +.alert-danger { + box-sizing: border-box; + width: 100%; + color: #D8000C; + background-color: #FFD2D2; + border-radius: 4px; + border: none; + padding: 10px; + margin-top: 20px; + font-weight: 500; + font-size: 16px; +} + +.alert-info { + box-sizing: border-box; + width: 100%; + color: #00529B; + background-color: #BDE5F8; + border-radius: 4px; + border: none; + padding: 10px; + margin-top: 20px; + font-weight: 500; + font-size: 16px; +} From 5d7c44266ba0355557e5a62ecca69428c5784d88 Mon Sep 17 00:00:00 2001 From: Phil Hagelberg Date: Wed, 30 Oct 2019 20:20:54 -0700 Subject: [PATCH 117/154] Change date formatting. --- lib/pleroma/web/static_fe/static_fe_view.ex | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/pleroma/web/static_fe/static_fe_view.ex b/lib/pleroma/web/static_fe/static_fe_view.ex index c19aa07e1..6128b2497 100644 --- a/lib/pleroma/web/static_fe/static_fe_view.ex +++ b/lib/pleroma/web/static_fe/static_fe_view.ex @@ -5,6 +5,8 @@ defmodule Pleroma.Web.StaticFE.StaticFEView do use Pleroma.Web, :view + alias Calendar.Strftime + alias Pleroma.Emoji.Formatter alias Pleroma.User alias Pleroma.Web.Gettext alias Pleroma.Web.MediaProxy @@ -31,6 +33,6 @@ def fetch_media_type(%{"mediaType" => mediaType}) do def format_date(date) do {:ok, date, _} = DateTime.from_iso8601(date) - Pleroma.Web.CommonAPI.Utils.format_asctime(date) + Strftime.strftime!(date, "%Y/%m/%d %l:%M:%S %p UTC") end end From 2ac1ece652621df9adf591255f4506564a8ace68 Mon Sep 17 00:00:00 2001 From: Phil Hagelberg Date: Wed, 30 Oct 2019 20:21:10 -0700 Subject: [PATCH 118/154] Fix a bug where reblogs were displayed under the wrong user. --- lib/pleroma/web/static_fe/static_fe_controller.ex | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/lib/pleroma/web/static_fe/static_fe_controller.ex b/lib/pleroma/web/static_fe/static_fe_controller.ex index d2e72b476..9b565d07d 100644 --- a/lib/pleroma/web/static_fe/static_fe_controller.ex +++ b/lib/pleroma/web/static_fe/static_fe_controller.ex @@ -34,7 +34,9 @@ def get_counts(%Activity{} = activity) do } end - def represent(%Activity{} = activity, %User{} = user, selected) do + def represent(%Activity{} = activity, selected) do + {:ok, user} = User.get_or_fetch(activity.object.data["actor"]) + %{ user: user, title: get_title(activity.object), @@ -48,11 +50,6 @@ def represent(%Activity{} = activity, %User{} = user, selected) do } end - def represent(%Activity{} = activity, selected) do - {:ok, user} = User.get_or_fetch(activity.data["actor"]) - represent(activity, user, selected) - end - def show_notice(%{assigns: %{notice_id: notice_id}} = conn, _params) do instance_name = Pleroma.Config.get([:instance, :name], "Pleroma") activity = Activity.get_by_id_with_object(notice_id) @@ -73,7 +70,7 @@ def show_user(%{assigns: %{username_or_id: username_or_id}} = conn, _params) do timeline = for activity <- ActivityPub.fetch_user_activities(user, nil, %{}) do - represent(activity, user, false) + represent(activity, false) end render(conn, "profile.html", %{user: user, timeline: timeline, instance_name: instance_name}) From 274cc18e8a585bd72353f9135c18aec0cb8e7ce3 Mon Sep 17 00:00:00 2001 From: Phil Hagelberg Date: Thu, 31 Oct 2019 17:44:43 -0700 Subject: [PATCH 119/154] Visually separate header. --- .../web/static_fe/static_fe_controller.ex | 10 +++--- lib/pleroma/web/static_fe/static_fe_view.ex | 1 + .../static_fe/static_fe/conversation.html.eex | 16 +++++---- .../static_fe/static_fe/profile.html.eex | 36 +++++++++++-------- priv/static/static/static-fe.css | 12 ++++--- 5 files changed, 45 insertions(+), 30 deletions(-) diff --git a/lib/pleroma/web/static_fe/static_fe_controller.ex b/lib/pleroma/web/static_fe/static_fe_controller.ex index 9b565d07d..c35657d8e 100644 --- a/lib/pleroma/web/static_fe/static_fe_controller.ex +++ b/lib/pleroma/web/static_fe/static_fe_controller.ex @@ -34,17 +34,17 @@ def get_counts(%Activity{} = activity) do } end - def represent(%Activity{} = activity, selected) do + def represent(%Activity{object: %Object{data: data}} = activity, selected) do {:ok, user} = User.get_or_fetch(activity.object.data["actor"]) %{ user: user, title: get_title(activity.object), - content: activity.object.data["content"] || nil, - attachment: activity.object.data["attachment"], + content: data["content"] || nil, + attachment: data["attachment"], link: Helpers.o_status_url(Pleroma.Web.Endpoint, :notice, activity.id), - published: activity.object.data["published"], - sensitive: activity.object.data["sensitive"], + published: data["published"], + sensitive: data["sensitive"], selected: selected, counts: get_counts(activity) } diff --git a/lib/pleroma/web/static_fe/static_fe_view.ex b/lib/pleroma/web/static_fe/static_fe_view.ex index 6128b2497..160261af9 100644 --- a/lib/pleroma/web/static_fe/static_fe_view.ex +++ b/lib/pleroma/web/static_fe/static_fe_view.ex @@ -8,6 +8,7 @@ defmodule Pleroma.Web.StaticFE.StaticFEView do alias Calendar.Strftime alias Pleroma.Emoji.Formatter alias Pleroma.User + alias Pleroma.Web.Endpoint alias Pleroma.Web.Gettext alias Pleroma.Web.MediaProxy alias Pleroma.Formatter diff --git a/lib/pleroma/web/templates/static_fe/static_fe/conversation.html.eex b/lib/pleroma/web/templates/static_fe/static_fe/conversation.html.eex index 3a1249df2..7ac4a9e5f 100644 --- a/lib/pleroma/web/templates/static_fe/static_fe/conversation.html.eex +++ b/lib/pleroma/web/templates/static_fe/static_fe/conversation.html.eex @@ -1,7 +1,11 @@ -

<%= link @instance_name, to: "/" %>

+
+

<%= link @instance_name, to: "/" %>

+
-
- <%= for activity <- @activities do %> - <%= render("_notice.html", activity) %> - <% end %> -
+
+
+ <%= for activity <- @activities do %> + <%= render("_notice.html", activity) %> + <% end %> +
+
diff --git a/lib/pleroma/web/templates/static_fe/static_fe/profile.html.eex b/lib/pleroma/web/templates/static_fe/static_fe/profile.html.eex index 8f2c74627..9b3d0509e 100644 --- a/lib/pleroma/web/templates/static_fe/static_fe/profile.html.eex +++ b/lib/pleroma/web/templates/static_fe/static_fe/profile.html.eex @@ -1,16 +1,22 @@ -

<%= link @instance_name, to: "/" %>

+
+

<%= link @instance_name, to: "/" %>

-

-
- - - -
- <%= raw (@user.name |> Formatter.emojify(emoji_for_user(@user))) %> -

-

<%= raw @user.bio %>

-
- <%= for activity <- @timeline do %> - <%= render("_notice.html", Map.put(activity, :selected, false)) %> - <% end %> -
+

+
+ + + +
+ <%= raw Formatter.emojify(@user.name, emoji_for_user(@user)) %> | + <%= link "@#{@user.nickname}@#{Endpoint.host()}", to: User.profile_url(@user) %> +

+

<%= raw @user.bio %>

+
+ +
+
+ <%= for activity <- @timeline do %> + <%= render("_notice.html", Map.put(activity, :selected, false)) %> + <% end %> +
+
diff --git a/priv/static/static/static-fe.css b/priv/static/static/static-fe.css index d6bb58c33..19c56387b 100644 --- a/priv/static/static/static-fe.css +++ b/priv/static/static/static-fe.css @@ -4,7 +4,7 @@ body { color: white; } -.container { +main { margin: 50px auto; max-width: 960px; padding: 40px; @@ -13,7 +13,11 @@ .container { } header { - border-bottom: 2em solid #282c37; + margin: 50px auto; + max-width: 960px; + padding: 40px; + background-color: #313543; + border-radius: 4px; } .activity { @@ -57,11 +61,11 @@ .h-card { margin-bottom: 8px; } -.h-card a { +header a, .h-card a { text-decoration: none; } -.h-card a:hover { +header a:hover, .h-card a:hover { text-decoration: underline; } From c6c706161e462bb6190cb4471e81e5a8c3b66d20 Mon Sep 17 00:00:00 2001 From: Phil Hagelberg Date: Thu, 31 Oct 2019 18:26:34 -0700 Subject: [PATCH 120/154] Make sure notice link is remote if the post is remote. --- lib/pleroma/web/static_fe/static_fe_controller.ex | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/pleroma/web/static_fe/static_fe_controller.ex b/lib/pleroma/web/static_fe/static_fe_controller.ex index c35657d8e..5f69218ce 100644 --- a/lib/pleroma/web/static_fe/static_fe_controller.ex +++ b/lib/pleroma/web/static_fe/static_fe_controller.ex @@ -37,12 +37,19 @@ def get_counts(%Activity{} = activity) do def represent(%Activity{object: %Object{data: data}} = activity, selected) do {:ok, user} = User.get_or_fetch(activity.object.data["actor"]) + link = + if user.local do + Helpers.o_status_url(Pleroma.Web.Endpoint, :notice, activity) + else + data["url"] || data["external_url"] || data["id"] + end + %{ user: user, title: get_title(activity.object), content: data["content"] || nil, attachment: data["attachment"], - link: Helpers.o_status_url(Pleroma.Web.Endpoint, :notice, activity.id), + link: link, published: data["published"], sensitive: data["sensitive"], selected: selected, From dc3b87d153415bee6a169b4c787f79dbee74c622 Mon Sep 17 00:00:00 2001 From: Phil Hagelberg Date: Fri, 1 Nov 2019 19:47:18 -0700 Subject: [PATCH 121/154] Move static FE routing into its own plug. Previously it was piggybacking on FallbackRedirectController for users and OStatusController for notices; now it's all in one place. --- lib/pleroma/plugs/static_fe_plug.ex | 14 +++++ lib/pleroma/web/ostatus/ostatus_controller.ex | 58 +++++++++---------- lib/pleroma/web/router.ex | 1 + .../web/static_fe/static_fe_controller.ex | 33 ++++------- 4 files changed, 53 insertions(+), 53 deletions(-) create mode 100644 lib/pleroma/plugs/static_fe_plug.ex diff --git a/lib/pleroma/plugs/static_fe_plug.ex b/lib/pleroma/plugs/static_fe_plug.ex new file mode 100644 index 000000000..d3abaf4cc --- /dev/null +++ b/lib/pleroma/plugs/static_fe_plug.ex @@ -0,0 +1,14 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2019 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + +defmodule Pleroma.Plugs.StaticFEPlug do + def init(options), do: options + + def call(conn, _) do + case Pleroma.Config.get([:instance, :static_fe], false) do + true -> Pleroma.Web.StaticFE.StaticFEController.call(conn, :show) + _ -> conn + end + end +end diff --git a/lib/pleroma/web/ostatus/ostatus_controller.ex b/lib/pleroma/web/ostatus/ostatus_controller.ex index be275977e..6958519de 100644 --- a/lib/pleroma/web/ostatus/ostatus_controller.ex +++ b/lib/pleroma/web/ostatus/ostatus_controller.ex @@ -76,41 +76,37 @@ def activity(%{assigns: %{format: format}} = conn, %{"uuid" => uuid}) do end def notice(%{assigns: %{format: format}} = conn, %{"id" => id}) do - if Pleroma.Config.get([:instance, :static_fe], false) do - Pleroma.Web.StaticFE.StaticFEController.call(conn, :show_notice) - else - with {_, %Activity{} = activity} <- {:activity, Activity.get_by_id_with_object(id)}, - {_, true} <- {:public?, Visibility.is_public?(activity)}, - %User{} = user <- User.get_cached_by_ap_id(activity.data["actor"]) do - cond do - format == "html" && activity.data["type"] == "Create" -> - %Object{} = object = Object.normalize(activity) + with {_, %Activity{} = activity} <- {:activity, Activity.get_by_id_with_object(id)}, + {_, true} <- {:public?, Visibility.is_public?(activity)}, + %User{} = user <- User.get_cached_by_ap_id(activity.data["actor"]) do + cond do + format == "html" && activity.data["type"] == "Create" -> + %Object{} = object = Object.normalize(activity) - RedirectController.redirector_with_meta( - conn, - %{ - activity_id: activity.id, - object: object, - url: Router.Helpers.o_status_url(Endpoint, :notice, activity.id), - user: user - } - ) + RedirectController.redirector_with_meta( + conn, + %{ + activity_id: activity.id, + object: object, + url: Router.Helpers.o_status_url(Endpoint, :notice, activity.id), + user: user + } + ) - format == "html" -> - RedirectController.redirector(conn, nil) + format == "html" -> + RedirectController.redirector(conn, nil) - true -> - represent_activity(conn, format, activity, user) - end - else - reason when reason in [{:public?, false}, {:activity, nil}] -> - conn - |> put_status(404) - |> RedirectController.redirector(nil, 404) - - e -> - e + true -> + represent_activity(conn, format, activity, user) end + else + reason when reason in [{:public?, false}, {:activity, nil}] -> + conn + |> put_status(404) + |> RedirectController.redirector(nil, 404) + + e -> + e end end diff --git a/lib/pleroma/web/router.ex b/lib/pleroma/web/router.ex index 8fb4aec13..ecf5f744c 100644 --- a/lib/pleroma/web/router.ex +++ b/lib/pleroma/web/router.ex @@ -495,6 +495,7 @@ defmodule Pleroma.Web.Router do pipeline :ostatus do plug(:accepts, ["html", "xml", "atom", "activity+json", "json"]) + plug(Pleroma.Plugs.StaticFEPlug) end pipeline :oembed do diff --git a/lib/pleroma/web/static_fe/static_fe_controller.ex b/lib/pleroma/web/static_fe/static_fe_controller.ex index 5f69218ce..96e30f317 100644 --- a/lib/pleroma/web/static_fe/static_fe_controller.ex +++ b/lib/pleroma/web/static_fe/static_fe_controller.ex @@ -14,7 +14,6 @@ defmodule Pleroma.Web.StaticFE.StaticFEController do plug(:put_layout, :static_fe) plug(:put_view, Pleroma.Web.StaticFE.StaticFEView) plug(:assign_id) - action_fallback(:not_found) defp get_title(%Object{data: %{"name" => name}}) when is_binary(name), do: name @@ -34,14 +33,15 @@ def get_counts(%Activity{} = activity) do } end + def represent(%Activity{} = activity), do: represent(activity, false) + def represent(%Activity{object: %Object{data: data}} = activity, selected) do {:ok, user} = User.get_or_fetch(activity.object.data["actor"]) link = - if user.local do - Helpers.o_status_url(Pleroma.Web.Endpoint, :notice, activity) - else - data["url"] || data["external_url"] || data["id"] + case user.local do + true -> Helpers.o_status_url(Pleroma.Web.Endpoint, :notice, activity) + _ -> data["url"] || data["external_url"] || data["id"] end %{ @@ -57,28 +57,27 @@ def represent(%Activity{object: %Object{data: data}} = activity, selected) do } end - def show_notice(%{assigns: %{notice_id: notice_id}} = conn, _params) do + def show(%{assigns: %{notice_id: notice_id}} = conn, _params) do instance_name = Pleroma.Config.get([:instance, :name], "Pleroma") activity = Activity.get_by_id_with_object(notice_id) context = activity.object.data["context"] activities = ActivityPub.fetch_activities_for_context(context, %{}) - represented = + timeline = for a <- Enum.reverse(activities) do represent(a, a.object.id == activity.object.id) end - render(conn, "conversation.html", %{activities: represented, instance_name: instance_name}) + render(conn, "conversation.html", %{activities: timeline, instance_name: instance_name}) end - def show_user(%{assigns: %{username_or_id: username_or_id}} = conn, _params) do + def show(%{assigns: %{username_or_id: username_or_id}} = conn, _params) do instance_name = Pleroma.Config.get([:instance, :name], "Pleroma") %User{} = user = User.get_cached_by_nickname_or_id(username_or_id) timeline = - for activity <- ActivityPub.fetch_user_activities(user, nil, %{}) do - represent(activity, false) - end + ActivityPub.fetch_user_activities(user, nil, %{}) + |> Enum.map(&represent/1) render(conn, "profile.html", %{user: user, timeline: timeline, instance_name: instance_name}) end @@ -89,15 +88,5 @@ def assign_id(%{path_info: ["notice", notice_id]} = conn, _opts), def assign_id(%{path_info: ["users", user_id]} = conn, _opts), do: assign(conn, :username_or_id, user_id) - def assign_id(%{path_info: [user_id]} = conn, _opts), - do: assign(conn, :username_or_id, user_id) - def assign_id(conn, _opts), do: conn - - # Fallback for unhandled types - def not_found(conn, _opts) do - conn - |> put_status(404) - |> text("Not found") - end end From e8bee35578fbbc442657baa4dee0047906b247a9 Mon Sep 17 00:00:00 2001 From: Phil Hagelberg Date: Sun, 3 Nov 2019 12:29:17 -0800 Subject: [PATCH 122/154] Static FE plug should only respond to text/html requests. --- lib/pleroma/plugs/static_fe_plug.ex | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/pleroma/plugs/static_fe_plug.ex b/lib/pleroma/plugs/static_fe_plug.ex index d3abaf4cc..dcbabc9df 100644 --- a/lib/pleroma/plugs/static_fe_plug.ex +++ b/lib/pleroma/plugs/static_fe_plug.ex @@ -5,9 +5,14 @@ defmodule Pleroma.Plugs.StaticFEPlug do def init(options), do: options + def accepts_html?({"accept", a}), do: String.contains?(a, "text/html") + def accepts_html?({_, _}), do: false + def call(conn, _) do - case Pleroma.Config.get([:instance, :static_fe], false) do - true -> Pleroma.Web.StaticFE.StaticFEController.call(conn, :show) + with true <- Pleroma.Config.get([:instance, :static_fe], false), + {_, _} <- Enum.find(conn.req_headers, &accepts_html?/1) do + Pleroma.Web.StaticFE.StaticFEController.call(conn, :show) + else _ -> conn end end From 8969c5522d0ff4b95705ce8dd1249aa76414fe0e Mon Sep 17 00:00:00 2001 From: Phil Hagelberg Date: Mon, 4 Nov 2019 22:02:10 -0800 Subject: [PATCH 123/154] Make many of the improvements suggested in review. --- lib/pleroma/plugs/static_fe_plug.ex | 21 ++++++++++++------- .../web/static_fe/static_fe_controller.ex | 16 ++++++-------- lib/pleroma/web/static_fe/static_fe_view.ex | 2 ++ .../web/templates/layout/static_fe.html.eex | 2 +- .../static_fe/static_fe/conversation.html.eex | 2 +- .../static_fe/static_fe/profile.html.eex | 2 +- 6 files changed, 25 insertions(+), 20 deletions(-) diff --git a/lib/pleroma/plugs/static_fe_plug.ex b/lib/pleroma/plugs/static_fe_plug.ex index dcbabc9df..2af45e52a 100644 --- a/lib/pleroma/plugs/static_fe_plug.ex +++ b/lib/pleroma/plugs/static_fe_plug.ex @@ -3,17 +3,24 @@ # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Plugs.StaticFEPlug do + import Plug.Conn + alias Pleroma.Web.StaticFE.StaticFEController + def init(options), do: options - def accepts_html?({"accept", a}), do: String.contains?(a, "text/html") - def accepts_html?({_, _}), do: false - def call(conn, _) do - with true <- Pleroma.Config.get([:instance, :static_fe], false), - {_, _} <- Enum.find(conn.req_headers, &accepts_html?/1) do - Pleroma.Web.StaticFE.StaticFEController.call(conn, :show) + if enabled?() and accepts_html?(conn) do + conn + |> StaticFEController.call(:show) + |> halt() else - _ -> conn + conn end end + + defp enabled?, do: Pleroma.Config.get([:instance, :static_fe], false) + + defp accepts_html?(conn) do + conn |> get_req_header("accept") |> List.first() |> String.contains?("text/html") + end end diff --git a/lib/pleroma/web/static_fe/static_fe_controller.ex b/lib/pleroma/web/static_fe/static_fe_controller.ex index 96e30f317..a00c6db4f 100644 --- a/lib/pleroma/web/static_fe/static_fe_controller.ex +++ b/lib/pleroma/web/static_fe/static_fe_controller.ex @@ -58,28 +58,24 @@ def represent(%Activity{object: %Object{data: data}} = activity, selected) do end def show(%{assigns: %{notice_id: notice_id}} = conn, _params) do - instance_name = Pleroma.Config.get([:instance, :name], "Pleroma") activity = Activity.get_by_id_with_object(notice_id) - context = activity.object.data["context"] - activities = ActivityPub.fetch_activities_for_context(context, %{}) - timeline = - for a <- Enum.reverse(activities) do - represent(a, a.object.id == activity.object.id) - end + activity.object.data["context"] + |> ActivityPub.fetch_activities_for_context(%{}) + |> Enum.reverse() + |> Enum.map(&represent(&1, &1.object.id == activity.object.id)) - render(conn, "conversation.html", %{activities: timeline, instance_name: instance_name}) + render(conn, "conversation.html", %{activities: timeline}) end def show(%{assigns: %{username_or_id: username_or_id}} = conn, _params) do - instance_name = Pleroma.Config.get([:instance, :name], "Pleroma") %User{} = user = User.get_cached_by_nickname_or_id(username_or_id) timeline = ActivityPub.fetch_user_activities(user, nil, %{}) |> Enum.map(&represent/1) - render(conn, "profile.html", %{user: user, timeline: timeline, instance_name: instance_name}) + render(conn, "profile.html", %{user: user, timeline: timeline}) end def assign_id(%{path_info: ["notice", notice_id]} = conn, _opts), diff --git a/lib/pleroma/web/static_fe/static_fe_view.ex b/lib/pleroma/web/static_fe/static_fe_view.ex index 160261af9..5612a06bb 100644 --- a/lib/pleroma/web/static_fe/static_fe_view.ex +++ b/lib/pleroma/web/static_fe/static_fe_view.ex @@ -36,4 +36,6 @@ def format_date(date) do {:ok, date, _} = DateTime.from_iso8601(date) Strftime.strftime!(date, "%Y/%m/%d %l:%M:%S %p UTC") end + + def instance_name, do: Pleroma.Config.get([:instance, :name], "Pleroma") end diff --git a/lib/pleroma/web/templates/layout/static_fe.html.eex b/lib/pleroma/web/templates/layout/static_fe.html.eex index 62b59f17c..4b889bb19 100644 --- a/lib/pleroma/web/templates/layout/static_fe.html.eex +++ b/lib/pleroma/web/templates/layout/static_fe.html.eex @@ -4,7 +4,7 @@ - <%= Application.get_env(:pleroma, :instance)[:name] %> + <%= Pleroma.Config.get([:instance, :name]) %> diff --git a/lib/pleroma/web/templates/static_fe/static_fe/conversation.html.eex b/lib/pleroma/web/templates/static_fe/static_fe/conversation.html.eex index 7ac4a9e5f..2acd84828 100644 --- a/lib/pleroma/web/templates/static_fe/static_fe/conversation.html.eex +++ b/lib/pleroma/web/templates/static_fe/static_fe/conversation.html.eex @@ -1,5 +1,5 @@
-

<%= link @instance_name, to: "/" %>

+

<%= link instance_name(), to: "/" %>

diff --git a/lib/pleroma/web/templates/static_fe/static_fe/profile.html.eex b/lib/pleroma/web/templates/static_fe/static_fe/profile.html.eex index 9b3d0509e..fa3df3b4e 100644 --- a/lib/pleroma/web/templates/static_fe/static_fe/profile.html.eex +++ b/lib/pleroma/web/templates/static_fe/static_fe/profile.html.eex @@ -1,5 +1,5 @@
-

<%= link @instance_name, to: "/" %>

+

<%= link instance_name(), to: "/" %>

From df2f59be911acd4626886befbc0c6bcd75752080 Mon Sep 17 00:00:00 2001 From: Phil Hagelberg Date: Mon, 4 Nov 2019 22:49:05 -0800 Subject: [PATCH 124/154] Pagination for user profiles. --- .../web/static_fe/static_fe_controller.ex | 22 +++++++++++++++---- .../static_fe/static_fe/profile.html.eex | 9 ++++++++ 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/lib/pleroma/web/static_fe/static_fe_controller.ex b/lib/pleroma/web/static_fe/static_fe_controller.ex index a00c6db4f..9f4eeaa36 100644 --- a/lib/pleroma/web/static_fe/static_fe_controller.ex +++ b/lib/pleroma/web/static_fe/static_fe_controller.ex @@ -15,6 +15,8 @@ defmodule Pleroma.Web.StaticFE.StaticFEController do plug(:put_view, Pleroma.Web.StaticFE.StaticFEView) plug(:assign_id) + @page_keys ["max_id", "min_id", "limit", "since_id", "order"] + defp get_title(%Object{data: %{"name" => name}}) when is_binary(name), do: name @@ -53,7 +55,8 @@ def represent(%Activity{object: %Object{data: data}} = activity, selected) do published: data["published"], sensitive: data["sensitive"], selected: selected, - counts: get_counts(activity) + counts: get_counts(activity), + id: activity.id } end @@ -68,14 +71,25 @@ def show(%{assigns: %{notice_id: notice_id}} = conn, _params) do render(conn, "conversation.html", %{activities: timeline}) end - def show(%{assigns: %{username_or_id: username_or_id}} = conn, _params) do + def show(%{assigns: %{username_or_id: username_or_id}} = conn, params) do %User{} = user = User.get_cached_by_nickname_or_id(username_or_id) timeline = - ActivityPub.fetch_user_activities(user, nil, %{}) + ActivityPub.fetch_user_activities(user, nil, Map.take(params, @page_keys)) |> Enum.map(&represent/1) - render(conn, "profile.html", %{user: user, timeline: timeline}) + prev_page_id = + (params["min_id"] || params["max_id"]) && + List.first(timeline) && List.first(timeline).id + + next_page_id = List.last(timeline) && List.last(timeline).id + + render(conn, "profile.html", %{ + user: user, + timeline: timeline, + prev_page_id: prev_page_id, + next_page_id: next_page_id + }) end def assign_id(%{path_info: ["notice", notice_id]} = conn, _opts), diff --git a/lib/pleroma/web/templates/static_fe/static_fe/profile.html.eex b/lib/pleroma/web/templates/static_fe/static_fe/profile.html.eex index fa3df3b4e..94063c92d 100644 --- a/lib/pleroma/web/templates/static_fe/static_fe/profile.html.eex +++ b/lib/pleroma/web/templates/static_fe/static_fe/profile.html.eex @@ -18,5 +18,14 @@ <%= for activity <- @timeline do %> <%= render("_notice.html", Map.put(activity, :selected, false)) %> <% end %> +

+ <%= if @prev_page_id do %> + <%= link "«", to: "?min_id=" <> @prev_page_id %> + <% end %> + <%= if @prev_page_id && @next_page_id, do: " | " %> + <%= if @next_page_id do %> + <%= link "»", to: "?max_id=" <> @next_page_id %> + <% end %> +

From 828259fb6517d35b5f950e07601bab0bdc5b5efd Mon Sep 17 00:00:00 2001 From: Phil Hagelberg Date: Mon, 4 Nov 2019 22:56:51 -0800 Subject: [PATCH 125/154] Catch 404s. --- .../web/static_fe/static_fe_controller.ex | 55 ++++++++++++------- 1 file changed, 34 insertions(+), 21 deletions(-) diff --git a/lib/pleroma/web/static_fe/static_fe_controller.ex b/lib/pleroma/web/static_fe/static_fe_controller.ex index 9f4eeaa36..4798cad24 100644 --- a/lib/pleroma/web/static_fe/static_fe_controller.ex +++ b/lib/pleroma/web/static_fe/static_fe_controller.ex @@ -61,35 +61,48 @@ def represent(%Activity{object: %Object{data: data}} = activity, selected) do end def show(%{assigns: %{notice_id: notice_id}} = conn, _params) do - activity = Activity.get_by_id_with_object(notice_id) - timeline = - activity.object.data["context"] - |> ActivityPub.fetch_activities_for_context(%{}) - |> Enum.reverse() - |> Enum.map(&represent(&1, &1.object.id == activity.object.id)) + case Activity.get_by_id_with_object(notice_id) do + %Activity{} = activity -> + timeline = + activity.object.data["context"] + |> ActivityPub.fetch_activities_for_context(%{}) + |> Enum.reverse() + |> Enum.map(&represent(&1, &1.object.id == activity.object.id)) - render(conn, "conversation.html", %{activities: timeline}) + render(conn, "conversation.html", %{activities: timeline}) + + _ -> + conn + |> put_status(404) + |> render_error(:not_found, "Notice not found") + end end def show(%{assigns: %{username_or_id: username_or_id}} = conn, params) do - %User{} = user = User.get_cached_by_nickname_or_id(username_or_id) + case User.get_cached_by_nickname_or_id(username_or_id) do + %User{} = user -> + timeline = + ActivityPub.fetch_user_activities(user, nil, Map.take(params, @page_keys)) + |> Enum.map(&represent/1) - timeline = - ActivityPub.fetch_user_activities(user, nil, Map.take(params, @page_keys)) - |> Enum.map(&represent/1) + prev_page_id = + (params["min_id"] || params["max_id"]) && + List.first(timeline) && List.first(timeline).id - prev_page_id = - (params["min_id"] || params["max_id"]) && - List.first(timeline) && List.first(timeline).id + next_page_id = List.last(timeline) && List.last(timeline).id - next_page_id = List.last(timeline) && List.last(timeline).id + render(conn, "profile.html", %{ + user: user, + timeline: timeline, + prev_page_id: prev_page_id, + next_page_id: next_page_id + }) - render(conn, "profile.html", %{ - user: user, - timeline: timeline, - prev_page_id: prev_page_id, - next_page_id: next_page_id - }) + _ -> + conn + |> put_status(404) + |> render_error(:not_found, "User not found") + end end def assign_id(%{path_info: ["notice", notice_id]} = conn, _opts), From bfd5d798262f0ecc7ebc260d92c766d39c0766de Mon Sep 17 00:00:00 2001 From: Phil Hagelberg Date: Tue, 5 Nov 2019 21:28:36 -0800 Subject: [PATCH 126/154] Include metadata in static FE conversations and profiles. --- lib/pleroma/web/static_fe/static_fe_controller.ex | 11 +++++++++-- lib/pleroma/web/templates/layout/static_fe.html.eex | 5 ++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/pleroma/web/static_fe/static_fe_controller.ex b/lib/pleroma/web/static_fe/static_fe_controller.ex index 4798cad24..10bd3fecd 100644 --- a/lib/pleroma/web/static_fe/static_fe_controller.ex +++ b/lib/pleroma/web/static_fe/static_fe_controller.ex @@ -9,6 +9,7 @@ defmodule Pleroma.Web.StaticFE.StaticFEController do alias Pleroma.Object alias Pleroma.User alias Pleroma.Web.ActivityPub.ActivityPub + alias Pleroma.Web.Metadata alias Pleroma.Web.Router.Helpers plug(:put_layout, :static_fe) @@ -63,13 +64,16 @@ def represent(%Activity{object: %Object{data: data}} = activity, selected) do def show(%{assigns: %{notice_id: notice_id}} = conn, _params) do case Activity.get_by_id_with_object(notice_id) do %Activity{} = activity -> + %User{} = user = User.get_by_ap_id(activity.object.data["actor"]) + meta = Metadata.build_tags(%{activity_id: notice_id, object: activity.object, user: user}) + timeline = activity.object.data["context"] |> ActivityPub.fetch_activities_for_context(%{}) |> Enum.reverse() |> Enum.map(&represent(&1, &1.object.id == activity.object.id)) - render(conn, "conversation.html", %{activities: timeline}) + render(conn, "conversation.html", %{activities: timeline, meta: meta}) _ -> conn @@ -81,6 +85,8 @@ def show(%{assigns: %{notice_id: notice_id}} = conn, _params) do def show(%{assigns: %{username_or_id: username_or_id}} = conn, params) do case User.get_cached_by_nickname_or_id(username_or_id) do %User{} = user -> + meta = Metadata.build_tags(%{user: user}) + timeline = ActivityPub.fetch_user_activities(user, nil, Map.take(params, @page_keys)) |> Enum.map(&represent/1) @@ -95,7 +101,8 @@ def show(%{assigns: %{username_or_id: username_or_id}} = conn, params) do user: user, timeline: timeline, prev_page_id: prev_page_id, - next_page_id: next_page_id + next_page_id: next_page_id, + meta: meta }) _ -> diff --git a/lib/pleroma/web/templates/layout/static_fe.html.eex b/lib/pleroma/web/templates/layout/static_fe.html.eex index 4b889bb19..5d820bb4b 100644 --- a/lib/pleroma/web/templates/layout/static_fe.html.eex +++ b/lib/pleroma/web/templates/layout/static_fe.html.eex @@ -3,9 +3,8 @@ - - <%= Pleroma.Config.get([:instance, :name]) %> - + <%= Pleroma.Config.get([:instance, :name]) %> + <%= Phoenix.HTML.raw(@meta || "") %> From e27c61218d292c5fbf268f27e81dbe22f93ba90f Mon Sep 17 00:00:00 2001 From: Phil Hagelberg Date: Tue, 5 Nov 2019 21:37:46 -0800 Subject: [PATCH 127/154] Expand subject content automatically when config is set. --- lib/pleroma/web/static_fe/static_fe_view.ex | 7 +++++++ .../web/templates/static_fe/static_fe/_notice.html.eex | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/pleroma/web/static_fe/static_fe_view.ex b/lib/pleroma/web/static_fe/static_fe_view.ex index 5612a06bb..72e667728 100644 --- a/lib/pleroma/web/static_fe/static_fe_view.ex +++ b/lib/pleroma/web/static_fe/static_fe_view.ex @@ -38,4 +38,11 @@ def format_date(date) do end def instance_name, do: Pleroma.Config.get([:instance, :name], "Pleroma") + + def open_content? do + Pleroma.Config.get( + [:frontend_configurations, :collapse_message_with_subjects], + true + ) + end end diff --git a/lib/pleroma/web/templates/static_fe/static_fe/_notice.html.eex b/lib/pleroma/web/templates/static_fe/static_fe/_notice.html.eex index 2a46dadb4..df5e5eedd 100644 --- a/lib/pleroma/web/templates/static_fe/static_fe/_notice.html.eex +++ b/lib/pleroma/web/templates/static_fe/static_fe/_notice.html.eex @@ -5,7 +5,7 @@ <%= render("_user_card.html", %{user: @user}) %>
<%= if @title != "" do %> -
+
open<% end %>> <%= raw @title %>
<%= raw @content %>
From b0080fa73010cda34215baeee230481b5c56dbca Mon Sep 17 00:00:00 2001 From: Phil Hagelberg Date: Tue, 5 Nov 2019 22:00:19 -0800 Subject: [PATCH 128/154] Render errors in HTML, not with JS. --- lib/pleroma/web/static_fe/static_fe_controller.ex | 4 ++-- lib/pleroma/web/templates/layout/static_fe.html.eex | 2 +- .../web/templates/static_fe/static_fe/error.html.eex | 7 +++++++ 3 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 lib/pleroma/web/templates/static_fe/static_fe/error.html.eex diff --git a/lib/pleroma/web/static_fe/static_fe_controller.ex b/lib/pleroma/web/static_fe/static_fe_controller.ex index 10bd3fecd..0be47d6b3 100644 --- a/lib/pleroma/web/static_fe/static_fe_controller.ex +++ b/lib/pleroma/web/static_fe/static_fe_controller.ex @@ -78,7 +78,7 @@ def show(%{assigns: %{notice_id: notice_id}} = conn, _params) do _ -> conn |> put_status(404) - |> render_error(:not_found, "Notice not found") + |> render("error.html", %{message: "Post not found.", meta: ""}) end end @@ -108,7 +108,7 @@ def show(%{assigns: %{username_or_id: username_or_id}} = conn, params) do _ -> conn |> put_status(404) - |> render_error(:not_found, "User not found") + |> render("error.html", %{message: "User not found.", meta: ""}) end end diff --git a/lib/pleroma/web/templates/layout/static_fe.html.eex b/lib/pleroma/web/templates/layout/static_fe.html.eex index 5d820bb4b..819632cec 100644 --- a/lib/pleroma/web/templates/layout/static_fe.html.eex +++ b/lib/pleroma/web/templates/layout/static_fe.html.eex @@ -4,7 +4,7 @@ <%= Pleroma.Config.get([:instance, :name]) %> - <%= Phoenix.HTML.raw(@meta || "") %> + <%= Phoenix.HTML.raw(assigns[:meta] || "") %> diff --git a/lib/pleroma/web/templates/static_fe/static_fe/error.html.eex b/lib/pleroma/web/templates/static_fe/static_fe/error.html.eex new file mode 100644 index 000000000..d98a1eba7 --- /dev/null +++ b/lib/pleroma/web/templates/static_fe/static_fe/error.html.eex @@ -0,0 +1,7 @@ +
+

<%= gettext("Oops") %>

+
+ +
+

<%= @message %>

+
From 886a07ba573a7dc566f51cfb44e69dac49f401cd Mon Sep 17 00:00:00 2001 From: Phil Hagelberg Date: Thu, 7 Nov 2019 19:31:28 -0800 Subject: [PATCH 129/154] Move static_fe config to its own section instead of in :instance. --- config/config.exs | 2 ++ lib/pleroma/plugs/static_fe_plug.ex | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/config/config.exs b/config/config.exs index 787809b27..685c18380 100644 --- a/config/config.exs +++ b/config/config.exs @@ -599,6 +599,8 @@ config :pleroma, Pleroma.Plugs.RemoteIp, enabled: false +config :pleroma, :static_fe, enabled: false + config :pleroma, :web_cache_ttl, activity_pub: nil, activity_pub_question: 30_000 diff --git a/lib/pleroma/plugs/static_fe_plug.ex b/lib/pleroma/plugs/static_fe_plug.ex index 2af45e52a..b3fb3c582 100644 --- a/lib/pleroma/plugs/static_fe_plug.ex +++ b/lib/pleroma/plugs/static_fe_plug.ex @@ -18,7 +18,7 @@ def call(conn, _) do end end - defp enabled?, do: Pleroma.Config.get([:instance, :static_fe], false) + defp enabled?, do: Pleroma.Config.get([:static_fe, :enabled], false) defp accepts_html?(conn) do conn |> get_req_header("accept") |> List.first() |> String.contains?("text/html") From 4729027f91852a921cf74f507fbc1ac8761a07f0 Mon Sep 17 00:00:00 2001 From: Phil Hagelberg Date: Thu, 7 Nov 2019 21:43:21 -0800 Subject: [PATCH 130/154] Prevent non-local notices from rendering. --- lib/pleroma/web/static_fe/static_fe_controller.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pleroma/web/static_fe/static_fe_controller.ex b/lib/pleroma/web/static_fe/static_fe_controller.ex index 0be47d6b3..66d2d0367 100644 --- a/lib/pleroma/web/static_fe/static_fe_controller.ex +++ b/lib/pleroma/web/static_fe/static_fe_controller.ex @@ -63,7 +63,7 @@ def represent(%Activity{object: %Object{data: data}} = activity, selected) do def show(%{assigns: %{notice_id: notice_id}} = conn, _params) do case Activity.get_by_id_with_object(notice_id) do - %Activity{} = activity -> + %Activity{local: true} = activity -> %User{} = user = User.get_by_ap_id(activity.object.data["actor"]) meta = Metadata.build_tags(%{activity_id: notice_id, object: activity.object, user: user}) From 2bf592f5dc16752bf640da94c169c9cd2d7a5ebb Mon Sep 17 00:00:00 2001 From: Phil Hagelberg Date: Thu, 7 Nov 2019 22:29:46 -0800 Subject: [PATCH 131/154] Add tests for static_fe controller. --- .../static_fe/static_fe_controller_test.exs | 91 +++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 test/web/static_fe/static_fe_controller_test.exs diff --git a/test/web/static_fe/static_fe_controller_test.exs b/test/web/static_fe/static_fe_controller_test.exs new file mode 100644 index 000000000..9099540bd --- /dev/null +++ b/test/web/static_fe/static_fe_controller_test.exs @@ -0,0 +1,91 @@ +defmodule Pleroma.Web.StaticFE.StaticFEControllerTest do + use Pleroma.Web.ConnCase + alias Pleroma.Web.CommonAPI + import Pleroma.Factory + + clear_config_all([:static_fe, :enabled]) do + Pleroma.Config.put([:static_fe, :enabled], true) + end + + describe "user profile page" do + test "just the profile as HTML", %{conn: conn} do + user = insert(:user) + conn = conn + |> put_req_header("accept", "text/html") + |> get("/users/#{user.nickname}") + + assert html_response(conn, 200) =~ user.nickname + end + + test "renders json unless there's an html accept header", %{conn: conn} do + user = insert(:user) + conn = conn + |> put_req_header("accept", "application/json") + |> get("/users/#{user.nickname}") + + assert json_response(conn, 200) + end + + test "404 when user not found", %{conn: conn} do + conn = conn + |> put_req_header("accept", "text/html") + |> get("/users/limpopo") + + assert html_response(conn, 404) =~ "not found" + end + + test "pagination", %{conn: conn} do + user = insert(:user) + Enum.map(1..30, fn i -> CommonAPI.post(user, %{"status" => "test#{i}"}) end) + conn = conn + |> put_req_header("accept", "text/html") + |> get("/users/#{user.nickname}") + html = html_response(conn, 200) + + assert html =~ ">test30<" + assert html =~ ">test11<" + refute html =~ ">test10<" + refute html =~ ">test1<" + end + + test "pagination, page 2", %{conn: conn} do + user = insert(:user) + activities = + Enum.map(1..30, fn i -> CommonAPI.post(user, %{"status" => "test#{i}"}) end) + {:ok, a11} = Enum.at(activities, 11) + conn = conn + |> put_req_header("accept", "text/html") + |> get("/users/#{user.nickname}?max_id=#{a11.id}") + html = html_response(conn, 200) + + assert html =~ ">test1<" + assert html =~ ">test10<" + refute html =~ ">test20<" + refute html =~ ">test29<" + end + end + + describe "notice rendering" do + test "single notice page", %{conn: conn} do + user = insert(:user) + {:ok, activity} = CommonAPI.post(user, %{"status" => "testing a thing!"}) + + conn = conn + |> put_req_header("accept", "text/html") + |> get("/notice/#{activity.id}") + + html = html_response(conn, 200) + assert html =~ "
" + assert html =~ user.nickname + assert html =~ "testing a thing!" + end + + test "404 when notice not found", %{conn: conn} do + conn = conn + |> put_req_header("accept", "text/html") + |> get("/notice/88c9c317") + + assert html_response(conn, 404) =~ "not found" + end + end +end From ef7c3bdc7a5d4047eca15b8469e1f7d7ab3bd39e Mon Sep 17 00:00:00 2001 From: Phil Hagelberg Date: Fri, 8 Nov 2019 08:55:32 -0800 Subject: [PATCH 132/154] Add some further test cases. Including like ... private visibility, cos that's super important. --- .../web/static_fe/static_fe_controller.ex | 24 ++-- .../static_fe/static_fe_controller_test.exs | 136 +++++++++++++++--- 2 files changed, 126 insertions(+), 34 deletions(-) diff --git a/lib/pleroma/web/static_fe/static_fe_controller.ex b/lib/pleroma/web/static_fe/static_fe_controller.ex index 66d2d0367..5e60c82b0 100644 --- a/lib/pleroma/web/static_fe/static_fe_controller.ex +++ b/lib/pleroma/web/static_fe/static_fe_controller.ex @@ -9,6 +9,7 @@ defmodule Pleroma.Web.StaticFE.StaticFEController do alias Pleroma.Object alias Pleroma.User alias Pleroma.Web.ActivityPub.ActivityPub + alias Pleroma.Web.ActivityPub.Visibility alias Pleroma.Web.Metadata alias Pleroma.Web.Router.Helpers @@ -62,19 +63,20 @@ def represent(%Activity{object: %Object{data: data}} = activity, selected) do end def show(%{assigns: %{notice_id: notice_id}} = conn, _params) do - case Activity.get_by_id_with_object(notice_id) do - %Activity{local: true} = activity -> - %User{} = user = User.get_by_ap_id(activity.object.data["actor"]) - meta = Metadata.build_tags(%{activity_id: notice_id, object: activity.object, user: user}) + with %Activity{local: true} = activity <- + Activity.get_by_id_with_object(notice_id), + true <- Visibility.is_public?(activity.object), + %User{} = user <- User.get_by_ap_id(activity.object.data["actor"]) do + meta = Metadata.build_tags(%{activity_id: notice_id, object: activity.object, user: user}) - timeline = - activity.object.data["context"] - |> ActivityPub.fetch_activities_for_context(%{}) - |> Enum.reverse() - |> Enum.map(&represent(&1, &1.object.id == activity.object.id)) - - render(conn, "conversation.html", %{activities: timeline, meta: meta}) + timeline = + activity.object.data["context"] + |> ActivityPub.fetch_activities_for_context(%{}) + |> Enum.reverse() + |> Enum.map(&represent(&1, &1.object.id == activity.object.id)) + render(conn, "conversation.html", %{activities: timeline, meta: meta}) + else _ -> conn |> put_status(404) diff --git a/test/web/static_fe/static_fe_controller_test.exs b/test/web/static_fe/static_fe_controller_test.exs index 9099540bd..e4bb78b01 100644 --- a/test/web/static_fe/static_fe_controller_test.exs +++ b/test/web/static_fe/static_fe_controller_test.exs @@ -1,6 +1,8 @@ defmodule Pleroma.Web.StaticFE.StaticFEControllerTest do use Pleroma.Web.ConnCase alias Pleroma.Web.CommonAPI + alias Pleroma.Web.ActivityPub.Transmogrifier + import Pleroma.Factory clear_config_all([:static_fe, :enabled]) do @@ -10,36 +12,60 @@ defmodule Pleroma.Web.StaticFE.StaticFEControllerTest do describe "user profile page" do test "just the profile as HTML", %{conn: conn} do user = insert(:user) - conn = conn - |> put_req_header("accept", "text/html") - |> get("/users/#{user.nickname}") + + conn = + conn + |> put_req_header("accept", "text/html") + |> get("/users/#{user.nickname}") assert html_response(conn, 200) =~ user.nickname end test "renders json unless there's an html accept header", %{conn: conn} do user = insert(:user) - conn = conn - |> put_req_header("accept", "application/json") - |> get("/users/#{user.nickname}") + + conn = + conn + |> put_req_header("accept", "application/json") + |> get("/users/#{user.nickname}") assert json_response(conn, 200) end test "404 when user not found", %{conn: conn} do - conn = conn - |> put_req_header("accept", "text/html") - |> get("/users/limpopo") + conn = + conn + |> put_req_header("accept", "text/html") + |> get("/users/limpopo") assert html_response(conn, 404) =~ "not found" end + test "profile does not include private messages", %{conn: conn} do + user = insert(:user) + CommonAPI.post(user, %{"status" => "public"}) + CommonAPI.post(user, %{"status" => "private", "visibility" => "private"}) + + conn = + conn + |> put_req_header("accept", "text/html") + |> get("/users/#{user.nickname}") + + html = html_response(conn, 200) + + assert html =~ ">public<" + refute html =~ ">private<" + end + test "pagination", %{conn: conn} do user = insert(:user) Enum.map(1..30, fn i -> CommonAPI.post(user, %{"status" => "test#{i}"}) end) - conn = conn - |> put_req_header("accept", "text/html") - |> get("/users/#{user.nickname}") + + conn = + conn + |> put_req_header("accept", "text/html") + |> get("/users/#{user.nickname}") + html = html_response(conn, 200) assert html =~ ">test30<" @@ -50,12 +76,14 @@ test "pagination", %{conn: conn} do test "pagination, page 2", %{conn: conn} do user = insert(:user) - activities = - Enum.map(1..30, fn i -> CommonAPI.post(user, %{"status" => "test#{i}"}) end) + activities = Enum.map(1..30, fn i -> CommonAPI.post(user, %{"status" => "test#{i}"}) end) {:ok, a11} = Enum.at(activities, 11) - conn = conn - |> put_req_header("accept", "text/html") - |> get("/users/#{user.nickname}?max_id=#{a11.id}") + + conn = + conn + |> put_req_header("accept", "text/html") + |> get("/users/#{user.nickname}?max_id=#{a11.id}") + html = html_response(conn, 200) assert html =~ ">test1<" @@ -70,9 +98,10 @@ test "single notice page", %{conn: conn} do user = insert(:user) {:ok, activity} = CommonAPI.post(user, %{"status" => "testing a thing!"}) - conn = conn - |> put_req_header("accept", "text/html") - |> get("/notice/#{activity.id}") + conn = + conn + |> put_req_header("accept", "text/html") + |> get("/notice/#{activity.id}") html = html_response(conn, 200) assert html =~ "
" @@ -80,10 +109,71 @@ test "single notice page", %{conn: conn} do assert html =~ "testing a thing!" end + test "shows the whole thread", %{conn: conn} do + user = insert(:user) + {:ok, activity} = CommonAPI.post(user, %{"status" => "space: the final frontier"}) + + CommonAPI.post(user, %{ + "status" => "these are the voyages or something", + "in_reply_to_status_id" => activity.id + }) + + conn = + conn + |> put_req_header("accept", "text/html") + |> get("/notice/#{activity.id}") + + html = html_response(conn, 200) + assert html =~ "the final frontier" + assert html =~ "voyages" + end + test "404 when notice not found", %{conn: conn} do - conn = conn - |> put_req_header("accept", "text/html") - |> get("/notice/88c9c317") + conn = + conn + |> put_req_header("accept", "text/html") + |> get("/notice/88c9c317") + + assert html_response(conn, 404) =~ "not found" + end + + test "404 for private status", %{conn: conn} do + user = insert(:user) + + {:ok, activity} = + CommonAPI.post(user, %{"status" => "don't show me!", "visibility" => "private"}) + + conn = + conn + |> put_req_header("accept", "text/html") + |> get("/notice/#{activity.id}") + + assert html_response(conn, 404) =~ "not found" + end + + test "404 for remote cached status", %{conn: conn} do + user = insert(:user) + + message = %{ + "@context" => "https://www.w3.org/ns/activitystreams", + "to" => user.follower_address, + "cc" => "https://www.w3.org/ns/activitystreams#Public", + "type" => "Create", + "object" => %{ + "content" => "blah blah blah", + "type" => "Note", + "attributedTo" => user.ap_id, + "inReplyTo" => nil + }, + "actor" => user.ap_id + } + + assert {:ok, activity} = Transmogrifier.handle_incoming(message) + + conn = + conn + |> put_req_header("accept", "text/html") + |> get("/notice/#{activity.id}") assert html_response(conn, 404) =~ "not found" end From 6ef804966461ff4351e6c8d3c867131c2af5d26a Mon Sep 17 00:00:00 2001 From: Phil Hagelberg Date: Sat, 9 Nov 2019 09:50:45 -0800 Subject: [PATCH 133/154] Add changelog entry, cheatsheet docs, and alphabetize. --- CHANGELOG.md | 1 + docs/configuration/cheatsheet.md | 7 +++++++ test/web/static_fe/static_fe_controller_test.exs | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b33d61819..7ae52a28b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Added - Refreshing poll results for remote polls - Authentication: Added rate limit for password-authorized actions / login existence checks +- Static Frontend: Add the ability to render user profiles and notices server-side without requiring JS app. - Mix task to re-count statuses for all users (`mix pleroma.count_statuses`) - Support for `X-Forwarded-For` and similar HTTP headers which used by reverse proxies to pass a real user IP address to the backend. Must not be enabled unless your instance is behind at least one reverse proxy (such as Nginx, Apache HTTPD or Varnish Cache).
diff --git a/docs/configuration/cheatsheet.md b/docs/configuration/cheatsheet.md index 8f609fcfd..dddd379d3 100644 --- a/docs/configuration/cheatsheet.md +++ b/docs/configuration/cheatsheet.md @@ -794,3 +794,10 @@ config :auto_linker, ] ``` +## :static_fe + +Render profiles and posts using server-generated HTML that is viewable without using JavaScript. + +Available options: + +* `enabled` - Enables the rendering of static HTML. Defaults to `false`. diff --git a/test/web/static_fe/static_fe_controller_test.exs b/test/web/static_fe/static_fe_controller_test.exs index e4bb78b01..effdfbeb3 100644 --- a/test/web/static_fe/static_fe_controller_test.exs +++ b/test/web/static_fe/static_fe_controller_test.exs @@ -1,7 +1,7 @@ defmodule Pleroma.Web.StaticFE.StaticFEControllerTest do use Pleroma.Web.ConnCase - alias Pleroma.Web.CommonAPI alias Pleroma.Web.ActivityPub.Transmogrifier + alias Pleroma.Web.CommonAPI import Pleroma.Factory From 3cc49cdb78bf14897030c476b00fb07064f2d74e Mon Sep 17 00:00:00 2001 From: Phil Hagelberg Date: Sat, 9 Nov 2019 18:26:19 -0800 Subject: [PATCH 134/154] Formatter moved to new module. --- lib/pleroma/web/static_fe/static_fe_view.ex | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/pleroma/web/static_fe/static_fe_view.ex b/lib/pleroma/web/static_fe/static_fe_view.ex index 72e667728..821ece9a9 100644 --- a/lib/pleroma/web/static_fe/static_fe_view.ex +++ b/lib/pleroma/web/static_fe/static_fe_view.ex @@ -11,7 +11,6 @@ defmodule Pleroma.Web.StaticFE.StaticFEView do alias Pleroma.Web.Endpoint alias Pleroma.Web.Gettext alias Pleroma.Web.MediaProxy - alias Pleroma.Formatter alias Pleroma.Web.Metadata.Utils alias Pleroma.Web.Router.Helpers From 9d0b989521dc181eea2e5912445df1c543457a90 Mon Sep 17 00:00:00 2001 From: Maksim Pechnikov Date: Fri, 8 Nov 2019 09:23:24 +0300 Subject: [PATCH 135/154] add subject to atom feed --- CHANGELOG.md | 1 + config/config.exs | 6 +++ lib/pleroma/web/activity_pub/activity_pub.ex | 1 - lib/pleroma/web/feed/feed_controller.ex | 21 +++++----- lib/pleroma/web/feed/feed_view.ex | 39 +++++++++-------- .../controllers/timeline_controller.ex | 2 - .../web/templates/feed/feed/_activity.xml.eex | 8 ++-- .../web/templates/feed/feed/feed.xml.eex | 2 +- test/web/activity_pub/activity_pub_test.exs | 42 +++++++++---------- test/web/feed/feed_controller_test.exs | 30 +++++++++++-- 10 files changed, 92 insertions(+), 60 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b33d61819..1eb7d14cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -58,6 +58,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Pleroma API: `POST /api/v1/pleroma/conversations/read` to mark all conversations as read - Mastodon API: Add `/api/v1/markers` for managing timeline read markers - Mastodon API: Add the `recipients` parameter to `GET /api/v1/conversations` +- Configuration: `feed` option for user atom feed.
### Fixed diff --git a/config/config.exs b/config/config.exs index 787809b27..7e1fe2a81 100644 --- a/config/config.exs +++ b/config/config.exs @@ -276,6 +276,12 @@ external_user_synchronization: true, extended_nickname_format: false +config :pleroma, :feed, + post_title: %{ + max_length: 100, + omission: "..." + } + config :pleroma, :markup, # XXX - unfortunately, inline images must be enabled by default right now, because # of custom emoji. Issue #275 discusses defanging that somehow. diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex index 51a9c6169..65dd251f3 100644 --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@ -568,7 +568,6 @@ def fetch_public_activities(opts \\ %{}, pagination \\ :keyset) do |> fetch_activities_query(opts) |> restrict_unlisted() |> Pagination.fetch_paginated(opts, pagination) - |> Enum.reverse() end @valid_visibilities ~w[direct unlisted public private] diff --git a/lib/pleroma/web/feed/feed_controller.ex b/lib/pleroma/web/feed/feed_controller.ex index d91ecef9c..d0e23007d 100644 --- a/lib/pleroma/web/feed/feed_controller.ex +++ b/lib/pleroma/web/feed/feed_controller.ex @@ -33,21 +33,22 @@ def feed_redirect(conn, %{"nickname" => nickname}) do def feed(conn, %{"nickname" => nickname} = params) do with {_, %User{} = user} <- {:fetch_user, User.get_cached_by_nickname(nickname)} do - query_params = - params - |> Map.take(["max_id"]) - |> Map.put("type", ["Create"]) - |> Map.put("whole_db", true) - |> Map.put("actor_id", user.ap_id) - activities = - query_params + %{ + "type" => ["Create"], + "whole_db" => true, + "actor_id" => user.ap_id + } + |> Map.merge(Map.take(params, ["max_id"])) |> ActivityPub.fetch_public_activities() - |> Enum.reverse() conn |> put_resp_content_type("application/atom+xml") - |> render("feed.xml", user: user, activities: activities) + |> render("feed.xml", + user: user, + activities: activities, + feed_config: Pleroma.Config.get([:feed]) + ) end end diff --git a/lib/pleroma/web/feed/feed_view.ex b/lib/pleroma/web/feed/feed_view.ex index 5eef1e757..bb1332fd3 100644 --- a/lib/pleroma/web/feed/feed_view.ex +++ b/lib/pleroma/web/feed/feed_view.ex @@ -6,12 +6,23 @@ defmodule Pleroma.Web.Feed.FeedView do use Phoenix.HTML use Pleroma.Web, :view + alias Pleroma.Formatter alias Pleroma.Object alias Pleroma.User alias Pleroma.Web.MediaProxy require Pleroma.Constants + def prepare_activity(activity) do + object = activity_object(activity) + + %{ + activity: activity, + data: Map.get(object, :data), + object: object + } + end + def most_recent_update(activities, user) do (List.first(activities) || user).updated_at |> NaiveDateTime.to_iso8601() @@ -23,31 +34,23 @@ def logo(user) do |> MediaProxy.url() end - def last_activity(activities) do - List.last(activities) + def last_activity(activities), do: List.last(activities) + + def activity_object(activity), do: Object.normalize(activity) + + def activity_title(%{data: %{"content" => content}}, opts \\ %{}) do + content + |> Formatter.truncate(opts[:max_length], opts[:omission]) + |> escape() end - def activity_object(activity) do - Object.normalize(activity) - end - - def activity_object_data(activity) do - activity - |> activity_object() - |> Map.get(:data) - end - - def activity_content(activity) do - content = activity_object_data(activity)["content"] - + def activity_content(%{data: %{"content" => content}}) do content |> String.replace(~r/[\n\r]/, "") |> escape() end - def activity_context(activity) do - activity.data["context"] - end + def activity_context(activity), do: activity.data["context"] def attachment_href(attachment) do attachment["url"] diff --git a/lib/pleroma/web/mastodon_api/controllers/timeline_controller.ex b/lib/pleroma/web/mastodon_api/controllers/timeline_controller.ex index f2d2d3ccb..384159336 100644 --- a/lib/pleroma/web/mastodon_api/controllers/timeline_controller.ex +++ b/lib/pleroma/web/mastodon_api/controllers/timeline_controller.ex @@ -71,7 +71,6 @@ def public(%{assigns: %{user: user}} = conn, params) do |> Map.put("blocking_user", user) |> Map.put("muting_user", user) |> ActivityPub.fetch_public_activities() - |> Enum.reverse() conn |> add_link_headers(activities, %{"local" => local_only}) @@ -110,7 +109,6 @@ def hashtag(%{assigns: %{user: user}} = conn, params) do |> Map.put("tag_all", tag_all) |> Map.put("tag_reject", tag_reject) |> ActivityPub.fetch_public_activities() - |> Enum.reverse() conn |> add_link_headers(activities, %{"local" => local_only}) diff --git a/lib/pleroma/web/templates/feed/feed/_activity.xml.eex b/lib/pleroma/web/templates/feed/feed/_activity.xml.eex index d1f5e903c..514eacaed 100644 --- a/lib/pleroma/web/templates/feed/feed/_activity.xml.eex +++ b/lib/pleroma/web/templates/feed/feed/_activity.xml.eex @@ -2,11 +2,13 @@ http://activitystrea.ms/schema/1.0/note http://activitystrea.ms/schema/1.0/post <%= @data["id"] %> - <%= "New note by #{@user.nickname}" %> - <%= activity_content(@activity) %> + <%= activity_title(@object, Keyword.get(@feed_config, :post_title, %{})) %> + <%= activity_content(@object) %> <%= @data["published"] %> <%= @data["published"] %> - <%= activity_context(@activity) %> + + <%= activity_context(@activity) %> + <%= if @data["summary"] do %> diff --git a/lib/pleroma/web/templates/feed/feed/feed.xml.eex b/lib/pleroma/web/templates/feed/feed/feed.xml.eex index 45df9dc09..5ae36d345 100644 --- a/lib/pleroma/web/templates/feed/feed/feed.xml.eex +++ b/lib/pleroma/web/templates/feed/feed/feed.xml.eex @@ -19,6 +19,6 @@ <% end %> <%= for activity <- @activities do %> - <%= render @view_module, "_activity.xml", Map.merge(assigns, %{activity: activity, data: activity_object_data(activity)}) %> + <%= render @view_module, "_activity.xml", Map.merge(assigns, prepare_activity(activity)) %> <% end %> diff --git a/test/web/activity_pub/activity_pub_test.exs b/test/web/activity_pub/activity_pub_test.exs index f29b8cc74..0d0281faf 100644 --- a/test/web/activity_pub/activity_pub_test.exs +++ b/test/web/activity_pub/activity_pub_test.exs @@ -734,56 +734,54 @@ test "retrieves public activities" do end test "retrieves a maximum of 20 activities" do - activities = ActivityBuilder.insert_list(30) - last_expected = List.last(activities) + ActivityBuilder.insert_list(10) + expected_activities = ActivityBuilder.insert_list(20) activities = ActivityPub.fetch_public_activities() - last = List.last(activities) + assert collect_ids(activities) == collect_ids(expected_activities) assert length(activities) == 20 - assert last == last_expected end test "retrieves ids starting from a since_id" do activities = ActivityBuilder.insert_list(30) - later_activities = ActivityBuilder.insert_list(10) + expected_activities = ActivityBuilder.insert_list(10) since_id = List.last(activities).id - last_expected = List.last(later_activities) activities = ActivityPub.fetch_public_activities(%{"since_id" => since_id}) - last = List.last(activities) + assert collect_ids(activities) == collect_ids(expected_activities) assert length(activities) == 10 - assert last == last_expected end test "retrieves ids up to max_id" do - _first_activities = ActivityBuilder.insert_list(10) - activities = ActivityBuilder.insert_list(20) - later_activities = ActivityBuilder.insert_list(10) - max_id = List.first(later_activities).id - last_expected = List.last(activities) + ActivityBuilder.insert_list(10) + expected_activities = ActivityBuilder.insert_list(20) + + %{id: max_id} = + 10 + |> ActivityBuilder.insert_list() + |> List.first() activities = ActivityPub.fetch_public_activities(%{"max_id" => max_id}) - last = List.last(activities) assert length(activities) == 20 - assert last == last_expected + assert collect_ids(activities) == collect_ids(expected_activities) end test "paginates via offset/limit" do - _first_activities = ActivityBuilder.insert_list(10) - activities = ActivityBuilder.insert_list(10) - _later_activities = ActivityBuilder.insert_list(10) - first_expected = List.first(activities) + _first_part_activities = ActivityBuilder.insert_list(10) + second_part_activities = ActivityBuilder.insert_list(10) + + later_activities = ActivityBuilder.insert_list(10) activities = ActivityPub.fetch_public_activities(%{"page" => "2", "page_size" => "20"}, :offset) - first = List.first(activities) - assert length(activities) == 20 - assert first == first_expected + + assert collect_ids(activities) == + collect_ids(second_part_activities) ++ collect_ids(later_activities) end test "doesn't return reblogs for users for whom reblogs have been muted" do diff --git a/test/web/feed/feed_controller_test.exs b/test/web/feed/feed_controller_test.exs index 1f44eae20..6f61acf43 100644 --- a/test/web/feed/feed_controller_test.exs +++ b/test/web/feed/feed_controller_test.exs @@ -6,16 +6,25 @@ defmodule Pleroma.Web.Feed.FeedControllerTest do use Pleroma.Web.ConnCase import Pleroma.Factory + import SweetXml alias Pleroma.Object alias Pleroma.User + clear_config([:feed]) + test "gets a feed", %{conn: conn} do + Pleroma.Config.put( + [:feed, :post_title], + %{max_length: 10, omission: "..."} + ) + activity = insert(:note_activity) note = insert(:note, data: %{ + "content" => "This is :moominmamma: note ", "attachment" => [ %{ "url" => [%{"mediaType" => "image/png", "href" => "https://pleroma.gov/image.png"}] @@ -26,15 +35,30 @@ test "gets a feed", %{conn: conn} do ) note_activity = insert(:note_activity, note: note) - object = Object.normalize(note_activity) user = User.get_cached_by_ap_id(note_activity.data["actor"]) - conn = + note2 = + insert(:note, + user: user, + data: %{"content" => "42 This is :moominmamma: note ", "inReplyTo" => activity.data["id"]} + ) + + _note_activity2 = insert(:note_activity, note: note2) + object = Object.normalize(note_activity) + + resp = conn |> put_req_header("content-type", "application/atom+xml") |> get("/users/#{user.nickname}/feed.atom") + |> response(200) - assert response(conn, 200) =~ object.data["content"] + activity_titles = + resp + |> SweetXml.parse() + |> SweetXml.xpath(~x"//entry/title/text()"l) + + assert activity_titles == ['42 This...', 'This is...'] + assert resp =~ object.data["content"] end test "returns 404 for a missing feed", %{conn: conn} do From 4885d403fee868c8d2b2ebedf1bbf37c36f0e333 Mon Sep 17 00:00:00 2001 From: lain Date: Sun, 10 Nov 2019 10:44:23 +0000 Subject: [PATCH 136/154] Apply suggestion to config/config.exs --- config/config.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/config.exs b/config/config.exs index 7e1fe2a81..a84f6e043 100644 --- a/config/config.exs +++ b/config/config.exs @@ -279,7 +279,7 @@ config :pleroma, :feed, post_title: %{ max_length: 100, - omission: "..." + omission: "…" } config :pleroma, :markup, From e08bd99bab2bcdcbcea68c383dd94952f60e0194 Mon Sep 17 00:00:00 2001 From: lain Date: Sun, 10 Nov 2019 11:02:34 +0000 Subject: [PATCH 137/154] Apply suggestion to config/config.exs --- config/config.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/config.exs b/config/config.exs index a84f6e043..7e1fe2a81 100644 --- a/config/config.exs +++ b/config/config.exs @@ -279,7 +279,7 @@ config :pleroma, :feed, post_title: %{ max_length: 100, - omission: "…" + omission: "..." } config :pleroma, :markup, From 4499a7a0751ec992a78a1023e8e34300f06e14b1 Mon Sep 17 00:00:00 2001 From: rinpatch Date: Sun, 10 Nov 2019 15:02:47 +0300 Subject: [PATCH 138/154] Disable attachment links by default Closes #1394 --- CHANGELOG.md | 1 + config/config.exs | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1eb7d14cd..4ec084dbd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Changed - **Breaking:** Elixir >=1.8 is now required (was >= 1.7) +- **Breaking:** attachment links (`config :pleroma, :instance, no_attachment_links` and `config :pleroma, Pleroma.Upload, link_name`) disabled by default - Replaced [pleroma_job_queue](https://git.pleroma.social/pleroma/pleroma_job_queue) and `Pleroma.Web.Federator.RetryQueue` with [Oban](https://github.com/sorentwo/oban) (see [`docs/config.md`](docs/config.md) on migrating customized worker / retry settings) - Introduced [quantum](https://github.com/quantum-elixir/quantum-core) job scheduler - Enabled `:instance, extended_nickname_format` in the default config diff --git a/config/config.exs b/config/config.exs index 7e1fe2a81..54de8fa9f 100644 --- a/config/config.exs +++ b/config/config.exs @@ -90,7 +90,7 @@ config :pleroma, Pleroma.Upload, uploader: Pleroma.Uploaders.Local, filters: [Pleroma.Upload.Filter.Dedupe], - link_name: true, + link_name: false, proxy_remote: false, proxy_opts: [ redirect_on_failure: false, @@ -257,7 +257,7 @@ mrf_transparency_exclusions: [], autofollowed_nicknames: [], max_pinned_statuses: 1, - no_attachment_links: false, + no_attachment_links: true, welcome_user_nickname: nil, welcome_message: nil, max_report_comment_size: 1000, From 6a4201e0b444748318845caddf0e972d0fac87d7 Mon Sep 17 00:00:00 2001 From: Alexander Date: Sun, 10 Nov 2019 22:54:37 +0300 Subject: [PATCH 139/154] fix for migrate task --- lib/mix/tasks/pleroma/config.ex | 2 +- lib/pleroma/docs/json.ex | 2 +- test/web/admin_api/admin_api_controller_test.exs | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/mix/tasks/pleroma/config.ex b/lib/mix/tasks/pleroma/config.ex index 11e4fde43..0e21408b2 100644 --- a/lib/mix/tasks/pleroma/config.ex +++ b/lib/mix/tasks/pleroma/config.ex @@ -45,7 +45,7 @@ def run(["migrate_from_db", env, delete?]) do if Pleroma.Config.get([:instance, :dynamic_configuration]) do config_path = "config/#{env}.exported_from_db.secret.exs" - {:ok, file} = File.open(config_path, [:write]) + {:ok, file} = File.open(config_path, [:write, :utf8]) IO.write(file, "use Mix.Config\r\n") Repo.all(Config) diff --git a/lib/pleroma/docs/json.ex b/lib/pleroma/docs/json.ex index 18ba01d58..f2a56d845 100644 --- a/lib/pleroma/docs/json.ex +++ b/lib/pleroma/docs/json.ex @@ -5,7 +5,7 @@ defmodule Pleroma.Docs.JSON do def process(descriptions) do config_path = "docs/generate_config.json" - with {:ok, file} <- File.open(config_path, [:write]), + with {:ok, file} <- File.open(config_path, [:write, :utf8]), json <- generate_json(descriptions), :ok <- IO.write(file, json), :ok <- File.close(file) do diff --git a/test/web/admin_api/admin_api_controller_test.exs b/test/web/admin_api/admin_api_controller_test.exs index 2a9e4f5a0..bc9235309 100644 --- a/test/web/admin_api/admin_api_controller_test.exs +++ b/test/web/admin_api/admin_api_controller_test.exs @@ -2269,6 +2269,10 @@ test "delete part of settings by atom subkeys", %{conn: conn} do Pleroma.Config.put([:instance, :dynamic_configuration], true) end + clear_config([:feed, :post_title]) do + Pleroma.Config.put([:feed, :post_title], %{max_length: 100, omission: "…"}) + end + test "transfer settings to DB and to file", %{conn: conn, admin: admin} do assert Pleroma.Repo.all(Pleroma.Web.AdminAPI.Config) == [] conn = get(conn, "/api/pleroma/admin/config/migrate_to_db") From 94627baa5cca524fe0c4f7043e25d71ed245626a Mon Sep 17 00:00:00 2001 From: Steven Fuchs Date: Mon, 11 Nov 2019 12:13:06 +0000 Subject: [PATCH 140/154] New rate limiter --- lib/pleroma/application.ex | 3 +- lib/pleroma/plugs/rate_limiter.ex | 131 -------- .../plugs/rate_limiter/limiter_supervisor.ex | 44 +++ .../plugs/rate_limiter/rate_limiter.ex | 227 ++++++++++++++ lib/pleroma/plugs/rate_limiter/supervisor.ex | 16 + .../controllers/account_controller.ex | 6 +- .../controllers/auth_controller.ex | 2 +- .../controllers/search_controller.ex | 2 +- .../controllers/status_controller.ex | 6 +- .../web/mongooseim/mongoose_im_controller.ex | 4 +- lib/pleroma/web/oauth/oauth_controller.ex | 3 +- lib/pleroma/web/ostatus/ostatus_controller.ex | 5 +- .../controllers/account_controller.ex | 2 +- mix.exs | 1 - mix.lock | 1 - test/plugs/rate_limiter_test.exs | 285 ++++++++++-------- 16 files changed, 464 insertions(+), 274 deletions(-) delete mode 100644 lib/pleroma/plugs/rate_limiter.ex create mode 100644 lib/pleroma/plugs/rate_limiter/limiter_supervisor.ex create mode 100644 lib/pleroma/plugs/rate_limiter/rate_limiter.ex create mode 100644 lib/pleroma/plugs/rate_limiter/supervisor.ex diff --git a/lib/pleroma/application.ex b/lib/pleroma/application.ex index d681eecc8..2b6a55f98 100644 --- a/lib/pleroma/application.ex +++ b/lib/pleroma/application.ex @@ -36,7 +36,8 @@ def start(_type, _args) do Pleroma.Emoji, Pleroma.Captcha, Pleroma.Daemons.ScheduledActivityDaemon, - Pleroma.Daemons.ActivityExpirationDaemon + Pleroma.Daemons.ActivityExpirationDaemon, + Pleroma.Plugs.RateLimiter.Supervisor ] ++ cachex_children() ++ hackney_pool_children() ++ diff --git a/lib/pleroma/plugs/rate_limiter.ex b/lib/pleroma/plugs/rate_limiter.ex deleted file mode 100644 index 31388f574..000000000 --- a/lib/pleroma/plugs/rate_limiter.ex +++ /dev/null @@ -1,131 +0,0 @@ -# Pleroma: A lightweight social networking server -# Copyright © 2017-2019 Pleroma Authors -# SPDX-License-Identifier: AGPL-3.0-only - -defmodule Pleroma.Plugs.RateLimiter do - @moduledoc """ - - ## Configuration - - A keyword list of rate limiters where a key is a limiter name and value is the limiter configuration. The basic configuration is a tuple where: - - * The first element: `scale` (Integer). The time scale in milliseconds. - * The second element: `limit` (Integer). How many requests to limit in the time scale provided. - - It is also possible to have different limits for unauthenticated and authenticated users: the keyword value must be a list of two tuples where the first one is a config for unauthenticated users and the second one is for authenticated. - - To disable a limiter set its value to `nil`. - - ### Example - - config :pleroma, :rate_limit, - one: {1000, 10}, - two: [{10_000, 10}, {10_000, 50}], - foobar: nil - - Here we have three limiters: - - * `one` which is not over 10req/1s - * `two` which has two limits: 10req/10s for unauthenticated users and 50req/10s for authenticated users - * `foobar` which is disabled - - ## Usage - - AllowedSyntax: - - plug(Pleroma.Plugs.RateLimiter, :limiter_name) - plug(Pleroma.Plugs.RateLimiter, {:limiter_name, options}) - - Allowed options: - - * `bucket_name` overrides bucket name (e.g. to have a separate limit for a set of actions) - * `params` appends values of specified request params (e.g. ["id"]) to bucket name - - Inside a controller: - - plug(Pleroma.Plugs.RateLimiter, :one when action == :one) - plug(Pleroma.Plugs.RateLimiter, :two when action in [:two, :three]) - - plug( - Pleroma.Plugs.RateLimiter, - {:status_id_action, bucket_name: "status_id_action:fav_unfav", params: ["id"]} - when action in ~w(fav_status unfav_status)a - ) - - or inside a router pipeline: - - pipeline :api do - ... - plug(Pleroma.Plugs.RateLimiter, :one) - ... - end - """ - import Pleroma.Web.TranslationHelpers - import Plug.Conn - - alias Pleroma.User - - def init(limiter_name) when is_atom(limiter_name) do - init({limiter_name, []}) - end - - def init({limiter_name, opts}) do - case Pleroma.Config.get([:rate_limit, limiter_name]) do - nil -> nil - config -> {limiter_name, config, opts} - end - end - - # Do not limit if there is no limiter configuration - def call(conn, nil), do: conn - - def call(conn, settings) do - case check_rate(conn, settings) do - {:ok, _count} -> - conn - - {:error, _count} -> - render_throttled_error(conn) - end - end - - defp bucket_name(conn, limiter_name, opts) do - bucket_name = opts[:bucket_name] || limiter_name - - if params_names = opts[:params] do - params_values = for p <- Enum.sort(params_names), do: conn.params[p] - Enum.join([bucket_name] ++ params_values, ":") - else - bucket_name - end - end - - defp check_rate( - %{assigns: %{user: %User{id: user_id}}} = conn, - {limiter_name, [_, {scale, limit}], opts} - ) do - bucket_name = bucket_name(conn, limiter_name, opts) - ExRated.check_rate("#{bucket_name}:#{user_id}", scale, limit) - end - - defp check_rate(conn, {limiter_name, [{scale, limit} | _], opts}) do - bucket_name = bucket_name(conn, limiter_name, opts) - ExRated.check_rate("#{bucket_name}:#{ip(conn)}", scale, limit) - end - - defp check_rate(conn, {limiter_name, {scale, limit}, opts}) do - check_rate(conn, {limiter_name, [{scale, limit}, {scale, limit}], opts}) - end - - def ip(%{remote_ip: remote_ip}) do - remote_ip - |> Tuple.to_list() - |> Enum.join(".") - end - - defp render_throttled_error(conn) do - conn - |> render_error(:too_many_requests, "Throttled") - |> halt() - end -end diff --git a/lib/pleroma/plugs/rate_limiter/limiter_supervisor.ex b/lib/pleroma/plugs/rate_limiter/limiter_supervisor.ex new file mode 100644 index 000000000..187582ede --- /dev/null +++ b/lib/pleroma/plugs/rate_limiter/limiter_supervisor.ex @@ -0,0 +1,44 @@ +defmodule Pleroma.Plugs.RateLimiter.LimiterSupervisor do + use DynamicSupervisor + + import Cachex.Spec + + def start_link(init_arg) do + DynamicSupervisor.start_link(__MODULE__, init_arg, name: __MODULE__) + end + + def add_limiter(limiter_name, expiration) do + {:ok, _pid} = + DynamicSupervisor.start_child( + __MODULE__, + %{ + id: String.to_atom("rl_#{limiter_name}"), + start: + {Cachex, :start_link, + [ + limiter_name, + [ + expiration: + expiration( + default: expiration, + interval: check_interval(expiration), + lazy: true + ) + ] + ]} + } + ) + end + + @impl true + def init(_init_arg) do + DynamicSupervisor.init(strategy: :one_for_one) + end + + defp check_interval(exp) do + (exp / 2) + |> Kernel.trunc() + |> Kernel.min(5000) + |> Kernel.max(1) + end +end diff --git a/lib/pleroma/plugs/rate_limiter/rate_limiter.ex b/lib/pleroma/plugs/rate_limiter/rate_limiter.ex new file mode 100644 index 000000000..d720508c8 --- /dev/null +++ b/lib/pleroma/plugs/rate_limiter/rate_limiter.ex @@ -0,0 +1,227 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2019 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + +defmodule Pleroma.Plugs.RateLimiter do + @moduledoc """ + + ## Configuration + + A keyword list of rate limiters where a key is a limiter name and value is the limiter configuration. The basic configuration is a tuple where: + + * The first element: `scale` (Integer). The time scale in milliseconds. + * The second element: `limit` (Integer). How many requests to limit in the time scale provided. + + It is also possible to have different limits for unauthenticated and authenticated users: the keyword value must be a list of two tuples where the first one is a config for unauthenticated users and the second one is for authenticated. + + To disable a limiter set its value to `nil`. + + ### Example + + config :pleroma, :rate_limit, + one: {1000, 10}, + two: [{10_000, 10}, {10_000, 50}], + foobar: nil + + Here we have three limiters: + + * `one` which is not over 10req/1s + * `two` which has two limits: 10req/10s for unauthenticated users and 50req/10s for authenticated users + * `foobar` which is disabled + + ## Usage + + AllowedSyntax: + + plug(Pleroma.Plugs.RateLimiter, name: :limiter_name) + plug(Pleroma.Plugs.RateLimiter, options) # :name is a required option + + Allowed options: + + * `name` required, always used to fetch the limit values from the config + * `bucket_name` overrides name for counting purposes (e.g. to have a separate limit for a set of actions) + * `params` appends values of specified request params (e.g. ["id"]) to bucket name + + Inside a controller: + + plug(Pleroma.Plugs.RateLimiter, [name: :one] when action == :one) + plug(Pleroma.Plugs.RateLimiter, [name: :two] when action in [:two, :three]) + + plug( + Pleroma.Plugs.RateLimiter, + [name: :status_id_action, bucket_name: "status_id_action:fav_unfav", params: ["id"]] + when action in ~w(fav_status unfav_status)a + ) + + or inside a router pipeline: + + pipeline :api do + ... + plug(Pleroma.Plugs.RateLimiter, name: :one) + ... + end + """ + import Pleroma.Web.TranslationHelpers + import Plug.Conn + + alias Pleroma.Plugs.RateLimiter.LimiterSupervisor + alias Pleroma.User + + def init(opts) do + limiter_name = Keyword.get(opts, :name) + + case Pleroma.Config.get([:rate_limit, limiter_name]) do + nil -> + nil + + config -> + name_root = Keyword.get(opts, :bucket_name, limiter_name) + + %{ + name: name_root, + limits: config, + opts: opts + } + end + end + + # Do not limit if there is no limiter configuration + def call(conn, nil), do: conn + + def call(conn, settings) do + settings + |> incorporate_conn_info(conn) + |> check_rate() + |> case do + {:ok, _count} -> + conn + + {:error, _count} -> + render_throttled_error(conn) + end + end + + def inspect_bucket(conn, name_root, settings) do + settings = + settings + |> incorporate_conn_info(conn) + + bucket_name = make_bucket_name(%{settings | name: name_root}) + key_name = make_key_name(settings) + limit = get_limits(settings) + + case Cachex.get(bucket_name, key_name) do + {:error, :no_cache} -> + {:err, :not_found} + + {:ok, nil} -> + {0, limit} + + {:ok, value} -> + {value, limit - value} + end + end + + defp check_rate(settings) do + bucket_name = make_bucket_name(settings) + key_name = make_key_name(settings) + limit = get_limits(settings) + + case Cachex.get_and_update(bucket_name, key_name, &increment_value(&1, limit)) do + {:commit, value} -> + {:ok, value} + + {:ignore, value} -> + {:error, value} + + {:error, :no_cache} -> + initialize_buckets(settings) + check_rate(settings) + end + end + + defp increment_value(nil, _limit), do: {:commit, 1} + + defp increment_value(val, limit) when val >= limit, do: {:ignore, val} + + defp increment_value(val, _limit), do: {:commit, val + 1} + + defp incorporate_conn_info(settings, %{assigns: %{user: %User{id: user_id}}, params: params}) do + Map.merge(settings, %{ + mode: :user, + conn_params: params, + conn_info: "#{user_id}" + }) + end + + defp incorporate_conn_info(settings, %{params: params} = conn) do + Map.merge(settings, %{ + mode: :anon, + conn_params: params, + conn_info: "#{ip(conn)}" + }) + end + + defp ip(%{remote_ip: remote_ip}) do + remote_ip + |> Tuple.to_list() + |> Enum.join(".") + end + + defp render_throttled_error(conn) do + conn + |> render_error(:too_many_requests, "Throttled") + |> halt() + end + + defp make_key_name(settings) do + "" + |> attach_params(settings) + |> attach_identity(settings) + end + + defp get_scale(_, {scale, _}), do: scale + + defp get_scale(:anon, [{scale, _}, {_, _}]), do: scale + + defp get_scale(:user, [{_, _}, {scale, _}]), do: scale + + defp get_limits(%{limits: {_scale, limit}}), do: limit + + defp get_limits(%{mode: :user, limits: [_, {_, limit}]}), do: limit + + defp get_limits(%{limits: [{_, limit}, _]}), do: limit + + defp make_bucket_name(%{mode: :user, name: name_root}), + do: user_bucket_name(name_root) + + defp make_bucket_name(%{mode: :anon, name: name_root}), + do: anon_bucket_name(name_root) + + defp attach_params(input, %{conn_params: conn_params, opts: opts}) do + param_string = + opts + |> Keyword.get(:params, []) + |> Enum.sort() + |> Enum.map(&Map.get(conn_params, &1, "")) + |> Enum.join(":") + + "#{input}#{param_string}" + end + + defp initialize_buckets(%{name: _name, limits: nil}), do: :ok + + defp initialize_buckets(%{name: name, limits: limits}) do + LimiterSupervisor.add_limiter(anon_bucket_name(name), get_scale(:anon, limits)) + LimiterSupervisor.add_limiter(user_bucket_name(name), get_scale(:user, limits)) + end + + defp attach_identity(base, %{mode: :user, conn_info: conn_info}), + do: "user:#{base}:#{conn_info}" + + defp attach_identity(base, %{mode: :anon, conn_info: conn_info}), + do: "ip:#{base}:#{conn_info}" + + defp user_bucket_name(name_root), do: "user:#{name_root}" |> String.to_atom() + defp anon_bucket_name(name_root), do: "anon:#{name_root}" |> String.to_atom() +end diff --git a/lib/pleroma/plugs/rate_limiter/supervisor.ex b/lib/pleroma/plugs/rate_limiter/supervisor.ex new file mode 100644 index 000000000..9672f7876 --- /dev/null +++ b/lib/pleroma/plugs/rate_limiter/supervisor.ex @@ -0,0 +1,16 @@ +defmodule Pleroma.Plugs.RateLimiter.Supervisor do + use Supervisor + + def start_link(opts) do + Supervisor.start_link(__MODULE__, opts, name: __MODULE__) + end + + def init(_args) do + children = [ + Pleroma.Plugs.RateLimiter.LimiterSupervisor + ] + + opts = [strategy: :one_for_one, name: Pleroma.Web.Streamer.Supervisor] + Supervisor.init(children, opts) + end +end diff --git a/lib/pleroma/web/mastodon_api/controllers/account_controller.ex b/lib/pleroma/web/mastodon_api/controllers/account_controller.ex index 73fad519e..5b01b964b 100644 --- a/lib/pleroma/web/mastodon_api/controllers/account_controller.ex +++ b/lib/pleroma/web/mastodon_api/controllers/account_controller.ex @@ -66,9 +66,9 @@ defmodule Pleroma.Web.MastodonAPI.AccountController do @relations [:follow, :unfollow] @needs_account ~W(followers following lists follow unfollow mute unmute block unblock)a - plug(RateLimiter, {:relations_id_action, params: ["id", "uri"]} when action in @relations) - plug(RateLimiter, :relations_actions when action in @relations) - plug(RateLimiter, :app_account_creation when action == :create) + plug(RateLimiter, [name: :relations_id_action, params: ["id", "uri"]] when action in @relations) + plug(RateLimiter, [name: :relations_actions] when action in @relations) + plug(RateLimiter, [name: :app_account_creation] when action == :create) plug(:assign_account_by_id when action in @needs_account) action_fallback(Pleroma.Web.MastodonAPI.FallbackController) diff --git a/lib/pleroma/web/mastodon_api/controllers/auth_controller.ex b/lib/pleroma/web/mastodon_api/controllers/auth_controller.ex index bfd5120ba..d9e51de7f 100644 --- a/lib/pleroma/web/mastodon_api/controllers/auth_controller.ex +++ b/lib/pleroma/web/mastodon_api/controllers/auth_controller.ex @@ -15,7 +15,7 @@ defmodule Pleroma.Web.MastodonAPI.AuthController do @local_mastodon_name "Mastodon-Local" - plug(Pleroma.Plugs.RateLimiter, :password_reset when action == :password_reset) + plug(Pleroma.Plugs.RateLimiter, [name: :password_reset] when action == :password_reset) @doc "GET /web/login" def login(%{assigns: %{user: %User{}}} = conn, _params) do diff --git a/lib/pleroma/web/mastodon_api/controllers/search_controller.ex b/lib/pleroma/web/mastodon_api/controllers/search_controller.ex index 6cfd68a84..0a929f55b 100644 --- a/lib/pleroma/web/mastodon_api/controllers/search_controller.ex +++ b/lib/pleroma/web/mastodon_api/controllers/search_controller.ex @@ -22,7 +22,7 @@ defmodule Pleroma.Web.MastodonAPI.SearchController do plug(Pleroma.Plugs.EnsurePublicOrAuthenticatedPlug) - plug(RateLimiter, :search when action in [:search, :search2, :account_search]) + plug(RateLimiter, [name: :search] when action in [:search, :search2, :account_search]) def account_search(%{assigns: %{user: user}} = conn, %{"q" => query} = params) do accounts = User.search(query, search_options(params, user)) diff --git a/lib/pleroma/web/mastodon_api/controllers/status_controller.ex b/lib/pleroma/web/mastodon_api/controllers/status_controller.ex index e5d016f63..74b223cf4 100644 --- a/lib/pleroma/web/mastodon_api/controllers/status_controller.ex +++ b/lib/pleroma/web/mastodon_api/controllers/status_controller.ex @@ -82,17 +82,17 @@ defmodule Pleroma.Web.MastodonAPI.StatusController do plug( RateLimiter, - {:status_id_action, bucket_name: "status_id_action:reblog_unreblog", params: ["id"]} + [name: :status_id_action, bucket_name: "status_id_action:reblog_unreblog", params: ["id"]] when action in ~w(reblog unreblog)a ) plug( RateLimiter, - {:status_id_action, bucket_name: "status_id_action:fav_unfav", params: ["id"]} + [name: :status_id_action, bucket_name: "status_id_action:fav_unfav", params: ["id"]] when action in ~w(favourite unfavourite)a ) - plug(RateLimiter, :statuses_actions when action in @rate_limited_status_actions) + plug(RateLimiter, [name: :statuses_actions] when action in @rate_limited_status_actions) action_fallback(Pleroma.Web.MastodonAPI.FallbackController) diff --git a/lib/pleroma/web/mongooseim/mongoose_im_controller.ex b/lib/pleroma/web/mongooseim/mongoose_im_controller.ex index 6ed181cff..358600e7d 100644 --- a/lib/pleroma/web/mongooseim/mongoose_im_controller.ex +++ b/lib/pleroma/web/mongooseim/mongoose_im_controller.ex @@ -10,8 +10,8 @@ defmodule Pleroma.Web.MongooseIM.MongooseIMController do alias Pleroma.Repo alias Pleroma.User - plug(RateLimiter, :authentication when action in [:user_exists, :check_password]) - plug(RateLimiter, {:authentication, params: ["user"]} when action == :check_password) + plug(RateLimiter, [name: :authentication] when action in [:user_exists, :check_password]) + plug(RateLimiter, [name: :authentication, params: ["user"]] when action == :check_password) def user_exists(conn, %{"user" => username}) do with %User{} <- Repo.get_by(User, nickname: username, local: true) do diff --git a/lib/pleroma/web/oauth/oauth_controller.ex b/lib/pleroma/web/oauth/oauth_controller.ex index fe71aca8c..1b1394787 100644 --- a/lib/pleroma/web/oauth/oauth_controller.ex +++ b/lib/pleroma/web/oauth/oauth_controller.ex @@ -6,6 +6,7 @@ defmodule Pleroma.Web.OAuth.OAuthController do use Pleroma.Web, :controller alias Pleroma.Helpers.UriHelper + alias Pleroma.Plugs.RateLimiter alias Pleroma.Registration alias Pleroma.Repo alias Pleroma.User @@ -24,7 +25,7 @@ defmodule Pleroma.Web.OAuth.OAuthController do plug(:fetch_session) plug(:fetch_flash) - plug(Pleroma.Plugs.RateLimiter, :authentication when action == :create_authorization) + plug(RateLimiter, [name: :authentication] when action == :create_authorization) action_fallback(Pleroma.Web.OAuth.FallbackController) diff --git a/lib/pleroma/web/ostatus/ostatus_controller.ex b/lib/pleroma/web/ostatus/ostatus_controller.ex index 6958519de..12a7c2365 100644 --- a/lib/pleroma/web/ostatus/ostatus_controller.ex +++ b/lib/pleroma/web/ostatus/ostatus_controller.ex @@ -8,6 +8,7 @@ defmodule Pleroma.Web.OStatus.OStatusController do alias Fallback.RedirectController alias Pleroma.Activity alias Pleroma.Object + alias Pleroma.Plugs.RateLimiter alias Pleroma.User alias Pleroma.Web.ActivityPub.ActivityPubController alias Pleroma.Web.ActivityPub.ObjectView @@ -17,8 +18,8 @@ defmodule Pleroma.Web.OStatus.OStatusController do alias Pleroma.Web.Router plug( - Pleroma.Plugs.RateLimiter, - {:ap_routes, params: ["uuid"]} when action in [:object, :activity] + RateLimiter, + [name: :ap_routes, params: ["uuid"]] when action in [:object, :activity] ) plug( diff --git a/lib/pleroma/web/pleroma_api/controllers/account_controller.ex b/lib/pleroma/web/pleroma_api/controllers/account_controller.ex index db6faac83..bc2f1017c 100644 --- a/lib/pleroma/web/pleroma_api/controllers/account_controller.ex +++ b/lib/pleroma/web/pleroma_api/controllers/account_controller.ex @@ -42,7 +42,7 @@ defmodule Pleroma.Web.PleromaAPI.AccountController do when action != :confirmation_resend ) - plug(RateLimiter, :account_confirmation_resend when action == :confirmation_resend) + plug(RateLimiter, [name: :account_confirmation_resend] when action == :confirmation_resend) plug(:assign_account_by_id when action in [:favourites, :subscribe, :unsubscribe]) plug(:put_view, Pleroma.Web.MastodonAPI.AccountView) diff --git a/mix.exs b/mix.exs index dd7c7e979..81ce4f25c 100644 --- a/mix.exs +++ b/mix.exs @@ -155,7 +155,6 @@ defp deps do {:joken, "~> 2.0"}, {:benchee, "~> 1.0"}, {:esshd, "~> 0.1.0", runtime: Application.get_env(:esshd, :enabled, false)}, - {:ex_rated, "~> 1.3"}, {:ex_const, "~> 0.2"}, {:plug_static_index_html, "~> 1.0.0"}, {:excoveralls, "~> 0.11.1", only: :test}, diff --git a/mix.lock b/mix.lock index 5b471fe3d..d4a80df77 100644 --- a/mix.lock +++ b/mix.lock @@ -33,7 +33,6 @@ "ex_const": {:hex, :ex_const, "0.2.4", "d06e540c9d834865b012a17407761455efa71d0ce91e5831e86881b9c9d82448", [:mix], [], "hexpm"}, "ex_doc": {:hex, :ex_doc, "0.21.2", "caca5bc28ed7b3bdc0b662f8afe2bee1eedb5c3cf7b322feeeb7c6ebbde089d6", [:mix], [{:earmark, "~> 1.3.3 or ~> 1.4", [hex: :earmark, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm"}, "ex_machina": {:hex, :ex_machina, "2.3.0", "92a5ad0a8b10ea6314b876a99c8c9e3f25f4dde71a2a835845b136b9adaf199a", [:mix], [{:ecto, "~> 2.2 or ~> 3.0", [hex: :ecto, repo: "hexpm", optional: true]}, {:ecto_sql, "~> 3.0", [hex: :ecto_sql, repo: "hexpm", optional: true]}], "hexpm"}, - "ex_rated": {:hex, :ex_rated, "1.3.3", "30ecbdabe91f7eaa9d37fa4e81c85ba420f371babeb9d1910adbcd79ec798d27", [:mix], [{:ex2ms, "~> 1.5", [hex: :ex2ms, repo: "hexpm", optional: false]}], "hexpm"}, "ex_syslogger": {:git, "https://github.com/slashmili/ex_syslogger.git", "f3963399047af17e038897c69e20d552e6899e1d", [tag: "1.4.0"]}, "excoveralls": {:hex, :excoveralls, "0.11.2", "0c6f2c8db7683b0caa9d490fb8125709c54580b4255ffa7ad35f3264b075a643", [:mix], [{:hackney, "~> 1.0", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm"}, "fast_html": {:hex, :fast_html, "0.99.3", "e7ce6245fed0635f4719a31cc409091ed17b2091165a4a1cffbf2ceac77abbf4", [:make, :mix], [], "hexpm"}, diff --git a/test/plugs/rate_limiter_test.exs b/test/plugs/rate_limiter_test.exs index 395095079..bacd621e1 100644 --- a/test/plugs/rate_limiter_test.exs +++ b/test/plugs/rate_limiter_test.exs @@ -12,163 +12,196 @@ defmodule Pleroma.Plugs.RateLimiterTest do # Note: each example must work with separate buckets in order to prevent concurrency issues - test "init/1" do - limiter_name = :test_init - Pleroma.Config.put([:rate_limit, limiter_name], {1, 1}) + describe "config" do + test "config is required for plug to work" do + limiter_name = :test_init + Pleroma.Config.put([:rate_limit, limiter_name], {1, 1}) - assert {limiter_name, {1, 1}, []} == RateLimiter.init(limiter_name) - assert nil == RateLimiter.init(:foo) + assert %{limits: {1, 1}, name: :test_init, opts: [name: :test_init]} == + RateLimiter.init(name: limiter_name) + + assert nil == RateLimiter.init(name: :foo) + end + + test "it restricts based on config values" do + limiter_name = :test_opts + scale = 60 + limit = 5 + + Pleroma.Config.put([:rate_limit, limiter_name], {scale, limit}) + + opts = RateLimiter.init(name: limiter_name) + conn = conn(:get, "/") + + for i <- 1..5 do + conn = RateLimiter.call(conn, opts) + assert {^i, _} = RateLimiter.inspect_bucket(conn, limiter_name, opts) + Process.sleep(10) + end + + conn = RateLimiter.call(conn, opts) + assert %{"error" => "Throttled"} = Phoenix.ConnTest.json_response(conn, :too_many_requests) + assert conn.halted + + Process.sleep(50) + + conn = conn(:get, "/") + + conn = RateLimiter.call(conn, opts) + assert {1, 4} = RateLimiter.inspect_bucket(conn, limiter_name, opts) + + refute conn.status == Plug.Conn.Status.code(:too_many_requests) + refute conn.resp_body + refute conn.halted + end end - test "ip/1" do - assert "127.0.0.1" == RateLimiter.ip(%{remote_ip: {127, 0, 0, 1}}) + describe "options" do + test "`bucket_name` option overrides default bucket name" do + limiter_name = :test_bucket_name + + Pleroma.Config.put([:rate_limit, limiter_name], {1000, 5}) + + base_bucket_name = "#{limiter_name}:group1" + opts = RateLimiter.init(name: limiter_name, bucket_name: base_bucket_name) + + conn = conn(:get, "/") + + RateLimiter.call(conn, opts) + assert {1, 4} = RateLimiter.inspect_bucket(conn, base_bucket_name, opts) + assert {:err, :not_found} = RateLimiter.inspect_bucket(conn, limiter_name, opts) + end + + test "`params` option allows different queries to be tracked independently" do + limiter_name = :test_params + Pleroma.Config.put([:rate_limit, limiter_name], {1000, 5}) + + opts = RateLimiter.init(name: limiter_name, params: ["id"]) + + conn = conn(:get, "/?id=1") + conn = Plug.Conn.fetch_query_params(conn) + conn_2 = conn(:get, "/?id=2") + + RateLimiter.call(conn, opts) + assert {1, 4} = RateLimiter.inspect_bucket(conn, limiter_name, opts) + assert {0, 5} = RateLimiter.inspect_bucket(conn_2, limiter_name, opts) + end + + test "it supports combination of options modifying bucket name" do + limiter_name = :test_options_combo + Pleroma.Config.put([:rate_limit, limiter_name], {1000, 5}) + + base_bucket_name = "#{limiter_name}:group1" + opts = RateLimiter.init(name: limiter_name, bucket_name: base_bucket_name, params: ["id"]) + id = "100" + + conn = conn(:get, "/?id=#{id}") + conn = Plug.Conn.fetch_query_params(conn) + conn_2 = conn(:get, "/?id=#{101}") + + RateLimiter.call(conn, opts) + assert {1, 4} = RateLimiter.inspect_bucket(conn, base_bucket_name, opts) + assert {0, 5} = RateLimiter.inspect_bucket(conn_2, base_bucket_name, opts) + end end - test "it restricts by opts" do - limiter_name = :test_opts - scale = 1000 - limit = 5 + describe "unauthenticated users" do + test "are restricted based on remote IP" do + limiter_name = :test_unauthenticated + Pleroma.Config.put([:rate_limit, limiter_name], [{1000, 5}, {1, 10}]) - Pleroma.Config.put([:rate_limit, limiter_name], {scale, limit}) + opts = RateLimiter.init(name: limiter_name) - opts = RateLimiter.init(limiter_name) - conn = conn(:get, "/") - bucket_name = "#{limiter_name}:#{RateLimiter.ip(conn)}" + conn = %{conn(:get, "/") | remote_ip: {127, 0, 0, 2}} + conn_2 = %{conn(:get, "/") | remote_ip: {127, 0, 0, 3}} - conn = RateLimiter.call(conn, opts) - assert {1, 4, _, _, _} = ExRated.inspect_bucket(bucket_name, scale, limit) + for i <- 1..5 do + conn = RateLimiter.call(conn, opts) + assert {^i, _} = RateLimiter.inspect_bucket(conn, limiter_name, opts) + refute conn.halted + end - conn = RateLimiter.call(conn, opts) - assert {2, 3, _, _, _} = ExRated.inspect_bucket(bucket_name, scale, limit) + conn = RateLimiter.call(conn, opts) - conn = RateLimiter.call(conn, opts) - assert {3, 2, _, _, _} = ExRated.inspect_bucket(bucket_name, scale, limit) + assert %{"error" => "Throttled"} = Phoenix.ConnTest.json_response(conn, :too_many_requests) + assert conn.halted - conn = RateLimiter.call(conn, opts) - assert {4, 1, _, _, _} = ExRated.inspect_bucket(bucket_name, scale, limit) + conn_2 = RateLimiter.call(conn_2, opts) + assert {1, 4} = RateLimiter.inspect_bucket(conn_2, limiter_name, opts) - conn = RateLimiter.call(conn, opts) - assert {5, 0, to_reset, _, _} = ExRated.inspect_bucket(bucket_name, scale, limit) - - conn = RateLimiter.call(conn, opts) - - assert %{"error" => "Throttled"} = Phoenix.ConnTest.json_response(conn, :too_many_requests) - assert conn.halted - - Process.sleep(to_reset) - - conn = conn(:get, "/") - - conn = RateLimiter.call(conn, opts) - assert {1, 4, _, _, _} = ExRated.inspect_bucket(bucket_name, scale, limit) - - refute conn.status == Plug.Conn.Status.code(:too_many_requests) - refute conn.resp_body - refute conn.halted + refute conn_2.status == Plug.Conn.Status.code(:too_many_requests) + refute conn_2.resp_body + refute conn_2.halted + end end - test "`bucket_name` option overrides default bucket name" do - limiter_name = :test_bucket_name - scale = 1000 - limit = 5 + describe "authenticated users" do + setup do + Ecto.Adapters.SQL.Sandbox.checkout(Pleroma.Repo) - Pleroma.Config.put([:rate_limit, limiter_name], {scale, limit}) - base_bucket_name = "#{limiter_name}:group1" - opts = RateLimiter.init({limiter_name, bucket_name: base_bucket_name}) + :ok + end - conn = conn(:get, "/") - default_bucket_name = "#{limiter_name}:#{RateLimiter.ip(conn)}" - customized_bucket_name = "#{base_bucket_name}:#{RateLimiter.ip(conn)}" + test "can have limits seperate from unauthenticated connections" do + limiter_name = :test_authenticated - RateLimiter.call(conn, opts) - assert {1, 4, _, _, _} = ExRated.inspect_bucket(customized_bucket_name, scale, limit) - assert {0, 5, _, _, _} = ExRated.inspect_bucket(default_bucket_name, scale, limit) - end + scale = 1000 + limit = 5 + Pleroma.Config.put([:rate_limit, limiter_name], [{1, 10}, {scale, limit}]) - test "`params` option appends specified params' values to bucket name" do - limiter_name = :test_params - scale = 1000 - limit = 5 + opts = RateLimiter.init(name: limiter_name) - Pleroma.Config.put([:rate_limit, limiter_name], {scale, limit}) - opts = RateLimiter.init({limiter_name, params: ["id"]}) - id = "1" + user = insert(:user) + conn = conn(:get, "/") |> assign(:user, user) - conn = conn(:get, "/?id=#{id}") - conn = Plug.Conn.fetch_query_params(conn) + for i <- 1..5 do + conn = RateLimiter.call(conn, opts) + assert {^i, _} = RateLimiter.inspect_bucket(conn, limiter_name, opts) + refute conn.halted + end - default_bucket_name = "#{limiter_name}:#{RateLimiter.ip(conn)}" - parametrized_bucket_name = "#{limiter_name}:#{id}:#{RateLimiter.ip(conn)}" + conn = RateLimiter.call(conn, opts) - RateLimiter.call(conn, opts) - assert {1, 4, _, _, _} = ExRated.inspect_bucket(parametrized_bucket_name, scale, limit) - assert {0, 5, _, _, _} = ExRated.inspect_bucket(default_bucket_name, scale, limit) - end + assert %{"error" => "Throttled"} = Phoenix.ConnTest.json_response(conn, :too_many_requests) + assert conn.halted - test "it supports combination of options modifying bucket name" do - limiter_name = :test_options_combo - scale = 1000 - limit = 5 + Process.sleep(1550) - Pleroma.Config.put([:rate_limit, limiter_name], {scale, limit}) - base_bucket_name = "#{limiter_name}:group1" - opts = RateLimiter.init({limiter_name, bucket_name: base_bucket_name, params: ["id"]}) - id = "100" + conn = conn(:get, "/") |> assign(:user, user) + conn = RateLimiter.call(conn, opts) + assert {1, 4} = RateLimiter.inspect_bucket(conn, limiter_name, opts) - conn = conn(:get, "/?id=#{id}") - conn = Plug.Conn.fetch_query_params(conn) + refute conn.status == Plug.Conn.Status.code(:too_many_requests) + refute conn.resp_body + refute conn.halted + end - default_bucket_name = "#{limiter_name}:#{RateLimiter.ip(conn)}" - parametrized_bucket_name = "#{base_bucket_name}:#{id}:#{RateLimiter.ip(conn)}" + test "diffrerent users are counted independently" do + limiter_name = :test_authenticated + Pleroma.Config.put([:rate_limit, limiter_name], [{1, 10}, {1000, 5}]) - RateLimiter.call(conn, opts) - assert {1, 4, _, _, _} = ExRated.inspect_bucket(parametrized_bucket_name, scale, limit) - assert {0, 5, _, _, _} = ExRated.inspect_bucket(default_bucket_name, scale, limit) - end + opts = RateLimiter.init(name: limiter_name) - test "optional limits for authenticated users" do - limiter_name = :test_authenticated - Ecto.Adapters.SQL.Sandbox.checkout(Pleroma.Repo) + user = insert(:user) + conn = conn(:get, "/") |> assign(:user, user) - scale = 1000 - limit = 5 - Pleroma.Config.put([:rate_limit, limiter_name], [{1, 10}, {scale, limit}]) + user_2 = insert(:user) + conn_2 = conn(:get, "/") |> assign(:user, user_2) - opts = RateLimiter.init(limiter_name) + for i <- 1..5 do + conn = RateLimiter.call(conn, opts) + assert {^i, _} = RateLimiter.inspect_bucket(conn, limiter_name, opts) + end - user = insert(:user) - conn = conn(:get, "/") |> assign(:user, user) - bucket_name = "#{limiter_name}:#{user.id}" + conn = RateLimiter.call(conn, opts) + assert %{"error" => "Throttled"} = Phoenix.ConnTest.json_response(conn, :too_many_requests) + assert conn.halted - conn = RateLimiter.call(conn, opts) - assert {1, 4, _, _, _} = ExRated.inspect_bucket(bucket_name, scale, limit) - - conn = RateLimiter.call(conn, opts) - assert {2, 3, _, _, _} = ExRated.inspect_bucket(bucket_name, scale, limit) - - conn = RateLimiter.call(conn, opts) - assert {3, 2, _, _, _} = ExRated.inspect_bucket(bucket_name, scale, limit) - - conn = RateLimiter.call(conn, opts) - assert {4, 1, _, _, _} = ExRated.inspect_bucket(bucket_name, scale, limit) - - conn = RateLimiter.call(conn, opts) - assert {5, 0, to_reset, _, _} = ExRated.inspect_bucket(bucket_name, scale, limit) - - conn = RateLimiter.call(conn, opts) - - assert %{"error" => "Throttled"} = Phoenix.ConnTest.json_response(conn, :too_many_requests) - assert conn.halted - - Process.sleep(to_reset) - - conn = conn(:get, "/") |> assign(:user, user) - - conn = RateLimiter.call(conn, opts) - assert {1, 4, _, _, _} = ExRated.inspect_bucket(bucket_name, scale, limit) - - refute conn.status == Plug.Conn.Status.code(:too_many_requests) - refute conn.resp_body - refute conn.halted + conn_2 = RateLimiter.call(conn_2, opts) + assert {1, 4} = RateLimiter.inspect_bucket(conn_2, limiter_name, opts) + refute conn_2.status == Plug.Conn.Status.code(:too_many_requests) + refute conn_2.resp_body + refute conn_2.halted + end end end From ab2e61238ee0dd5df0744c8bd8a7ffb089c4a0f8 Mon Sep 17 00:00:00 2001 From: Egor Kislitsyn Date: Mon, 11 Nov 2019 19:13:07 +0700 Subject: [PATCH 141/154] Add a warning about Pg version to the RUM related docs --- docs/configuration/cheatsheet.md | 6 +++++- docs/installation/otp_en.md | 8 ++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/docs/configuration/cheatsheet.md b/docs/configuration/cheatsheet.md index 8f609fcfd..61783cf3f 100644 --- a/docs/configuration/cheatsheet.md +++ b/docs/configuration/cheatsheet.md @@ -523,7 +523,7 @@ config :pleroma, :workers, Configuration for [Quantum](https://github.com/quantum-elixir/quantum-core) jobs scheduler. -See [Quantum readme](https://github.com/quantum-elixir/quantum-core#usage) for the list of supported options. +See [Quantum readme](https://github.com/quantum-elixir/quantum-core#usage) for the list of supported options. Example: @@ -593,6 +593,10 @@ See the [Quack Github](https://github.com/azohra/quack) for more details ## Database options ### RUM indexing for full text search + +!!! warning + It is recommended to use PostgreSQL v11 or newer. We have seen some minor issues with lower PostgreSQL versions. + * `rum_enabled`: If RUM indexes should be used. Defaults to `false`. RUM indexes are an alternative indexing scheme that is not included in PostgreSQL by default. While they may eventually be mainlined, for now they have to be installed as a PostgreSQL extension from https://github.com/postgrespro/rum. diff --git a/docs/installation/otp_en.md b/docs/installation/otp_en.md index c028f4229..965e30e2a 100644 --- a/docs/installation/otp_en.md +++ b/docs/installation/otp_en.md @@ -42,6 +42,10 @@ apk add curl unzip ncurses postgresql postgresql-contrib nginx certbot ## Setup ### Configuring PostgreSQL #### (Optional) Installing RUM indexes + +!!! warning + It is recommended to use PostgreSQL v11 or newer. We have seen some minor issues with lower PostgreSQL versions. + RUM indexes are an alternative indexing scheme that is not included in PostgreSQL by default. You can read more about them on the [Configuration page](../configuration/cheatsheet.md#rum-indexing-for-full-text-search). They are completely optional and most of the time are not worth it, especially if you are running a single user instance (unless you absolutely need ordered search results). Debian/Ubuntu (available only on Buster/19.04): @@ -74,7 +78,7 @@ rc-service postgresql restart # Create the Pleroma user adduser --system --shell /bin/false --home /opt/pleroma pleroma -# Set the flavour environment variable to the string you got in Detecting flavour section. +# Set the flavour environment variable to the string you got in Detecting flavour section. # For example if the flavour is `arm64-musl` the command will be export FLAVOUR="arm64-musl" @@ -180,7 +184,7 @@ rc-service pleroma start rc-update add pleroma ``` -If everything worked, you should see Pleroma-FE when visiting your domain. If that didn't happen, try reviewing the installation steps, starting Pleroma in the foreground and seeing if there are any errrors. +If everything worked, you should see Pleroma-FE when visiting your domain. If that didn't happen, try reviewing the installation steps, starting Pleroma in the foreground and seeing if there are any errrors. Still doesn't work? Feel free to contact us on [#pleroma on freenode](https://webchat.freenode.net/?channels=%23pleroma) or via matrix at , you can also [file an issue on our Gitlab](https://git.pleroma.social/pleroma/pleroma/issues/new) From 86d821a96eb9da10455c90c0638cc0a3c594ad7f Mon Sep 17 00:00:00 2001 From: lain Date: Mon, 11 Nov 2019 13:37:56 +0100 Subject: [PATCH 142/154] Dokku deploys: Keep the git dir so version number generation works. --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0f8a0659b..4f448a784 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -113,6 +113,7 @@ review_app: - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - - ssh-keyscan -H "pleroma.online" >> ~/.ssh/known_hosts - (ssh -t dokku@pleroma.online -- apps:create "$CI_ENVIRONMENT_SLUG") || true + - (ssh -t dokku@pleroma.online -- git:set "$CI_ENVIRONMENT_SLUG" keep-git-dir true) || true - ssh -t dokku@pleroma.online -- config:set "$CI_ENVIRONMENT_SLUG" APP_NAME="$CI_ENVIRONMENT_SLUG" APP_HOST="$CI_ENVIRONMENT_SLUG.pleroma.online" MIX_ENV=dokku - (ssh -t dokku@pleroma.online -- postgres:create $(echo $CI_ENVIRONMENT_SLUG | sed -e 's/-/_/g')_db) || true - (ssh -t dokku@pleroma.online -- postgres:link $(echo $CI_ENVIRONMENT_SLUG | sed -e 's/-/_/g')_db "$CI_ENVIRONMENT_SLUG") || true From 7ba30cf8b6ee86297562d6af50b267ec0967a63b Mon Sep 17 00:00:00 2001 From: Egor Kislitsyn Date: Mon, 11 Nov 2019 19:47:33 +0700 Subject: [PATCH 143/154] Use PG12 in CI for the RUM pipeline --- .gitlab-ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0f8a0659b..b801f28c4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -34,7 +34,7 @@ benchmark: variables: MIX_ENV: benchmark services: - - name: lainsoykaf/postgres-with-rum + - name: postgres:9.6 alias: postgres command: ["postgres", "-c", "fsync=off", "-c", "synchronous_commit=off", "-c", "full_page_writes=off"] script: @@ -46,7 +46,7 @@ benchmark: unit-testing: stage: test services: - - name: lainsoykaf/postgres-with-rum + - name: postgres:9.6 alias: postgres command: ["postgres", "-c", "fsync=off", "-c", "synchronous_commit=off", "-c", "full_page_writes=off"] script: @@ -58,7 +58,7 @@ unit-testing: unit-testing-rum: stage: test services: - - name: lainsoykaf/postgres-with-rum + - name: minibikini/postgres-with-rum:12 alias: postgres command: ["postgres", "-c", "fsync=off", "-c", "synchronous_commit=off", "-c", "full_page_writes=off"] variables: @@ -138,7 +138,7 @@ stop_review_app: - ssh -t dokku@pleroma.online -- --force postgres:destroy $(echo $CI_ENVIRONMENT_SLUG | sed -e 's/-/_/g')_db amd64: - stage: release + stage: release # TODO: Replace with upstream image when 1.9.0 comes out image: rinpatch/elixir:1.9.0-rc.0 only: &release-only From 72cc92259ea2f9d299943b845f7a339255cf99fe Mon Sep 17 00:00:00 2001 From: lain Date: Mon, 11 Nov 2019 12:49:18 +0000 Subject: [PATCH 144/154] Default config: Use extended nickname format --- config/config.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/config.exs b/config/config.exs index 54de8fa9f..17d15256f 100644 --- a/config/config.exs +++ b/config/config.exs @@ -274,7 +274,7 @@ account_field_name_length: 512, account_field_value_length: 2048, external_user_synchronization: true, - extended_nickname_format: false + extended_nickname_format: true config :pleroma, :feed, post_title: %{ From 827b938502627e048a486fa6e17a181acaf0b508 Mon Sep 17 00:00:00 2001 From: rinpatch Date: Mon, 11 Nov 2019 17:05:30 +0300 Subject: [PATCH 145/154] Add a changelog entry for !1940 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ec084dbd..727dde9be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -64,6 +64,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Fixed - Report emails now include functional links to profiles of remote user accounts +- Not being able to log in to some third-party apps when logged in to MastoFE
API Changes From b39b49cc146945ab86db272ae2cd1fe8fad3d9d5 Mon Sep 17 00:00:00 2001 From: href Date: Mon, 11 Nov 2019 19:03:43 +0100 Subject: [PATCH 146/154] report federating status in nodeinfo --- .../web/nodeinfo/nodeinfo_controller.ex | 1 + test/web/node_info_test.exs | 24 +++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/lib/pleroma/web/nodeinfo/nodeinfo_controller.ex b/lib/pleroma/web/nodeinfo/nodeinfo_controller.ex index d7ae503f6..486b9f6a4 100644 --- a/lib/pleroma/web/nodeinfo/nodeinfo_controller.ex +++ b/lib/pleroma/web/nodeinfo/nodeinfo_controller.ex @@ -46,6 +46,7 @@ def raw_nodeinfo do data |> Map.merge(%{quarantined_instances: quarantined}) + |> Map.put(:enabled, Config.get([:instance, :federating])) else %{} end diff --git a/test/web/node_info_test.exs b/test/web/node_info_test.exs index a3281b25b..6cc876602 100644 --- a/test/web/node_info_test.exs +++ b/test/web/node_info_test.exs @@ -84,6 +84,30 @@ test "it returns the safe_dm_mentions feature if enabled", %{conn: conn} do Pleroma.Config.put([:instance, :safe_dm_mentions], option) end + test "it shows if federation is enabled/disabled", %{conn: conn} do + original = Pleroma.Config.get([:instance, :federating]) + + Pleroma.Config.put([:instance, :federating], true) + + response = + conn + |> get("/nodeinfo/2.1.json") + |> json_response(:ok) + + assert response["metadata"]["federation"]["enabled"] == true + + Pleroma.Config.put([:instance, :federating], false) + + response = + conn + |> get("/nodeinfo/2.1.json") + |> json_response(:ok) + + assert response["metadata"]["federation"]["enabled"] == false + + Pleroma.Config.put([:instance, :federating], original) + end + test "it shows MRF transparency data if enabled", %{conn: conn} do config = Pleroma.Config.get([:instance, :rewrite_policy]) Pleroma.Config.put([:instance, :rewrite_policy], [Pleroma.Web.ActivityPub.MRF.SimplePolicy]) From 04473677ccd70281172b8295b44feebb01168386 Mon Sep 17 00:00:00 2001 From: rinpatch Date: Mon, 11 Nov 2019 23:24:15 +0300 Subject: [PATCH 147/154] docs: move static-fe docs under a proper category --- docs/configuration/cheatsheet.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/configuration/cheatsheet.md b/docs/configuration/cheatsheet.md index 6c7f60203..7832f6962 100644 --- a/docs/configuration/cheatsheet.md +++ b/docs/configuration/cheatsheet.md @@ -180,6 +180,14 @@ config :pleroma, :frontend_configurations, These settings **need to be complete**, they will override the defaults. +### :static_fe + +Render profiles and posts using server-generated HTML that is viewable without using JavaScript. + +Available options: + +* `enabled` - Enables the rendering of static HTML. Defaults to `false`. + ### :assets This section configures assets to be used with various frontends. Currently the only option @@ -797,11 +805,3 @@ config :auto_linker, rel: "ugc" ] ``` - -## :static_fe - -Render profiles and posts using server-generated HTML that is viewable without using JavaScript. - -Available options: - -* `enabled` - Enables the rendering of static HTML. Defaults to `false`. From e835cd97f6988522dae8f60a0381f0f93c6abb2d Mon Sep 17 00:00:00 2001 From: lain Date: Tue, 12 Nov 2019 12:07:17 +0100 Subject: [PATCH 148/154] Containment: Add a catch-all clause to contain_origin. --- lib/pleroma/object/containment.ex | 2 ++ test/object/containment_test.exs | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/lib/pleroma/object/containment.ex b/lib/pleroma/object/containment.ex index a1f9c1250..25aa32f60 100644 --- a/lib/pleroma/object/containment.ex +++ b/lib/pleroma/object/containment.ex @@ -64,6 +64,8 @@ def contain_origin(id, %{"actor" => _actor} = params) do def contain_origin(id, %{"attributedTo" => actor} = params), do: contain_origin(id, Map.put(params, "actor", actor)) + def contain_origin(_id, _data), do: :error + def contain_origin_from_id(id, %{"id" => other_id} = _params) when is_binary(other_id) do id_uri = URI.parse(id) other_uri = URI.parse(other_id) diff --git a/test/object/containment_test.exs b/test/object/containment_test.exs index 71fe5204c..7636803a6 100644 --- a/test/object/containment_test.exs +++ b/test/object/containment_test.exs @@ -17,6 +17,16 @@ defmodule Pleroma.Object.ContainmentTest do end describe "general origin containment" do + test "works for completely actorless posts" do + assert :error == + Containment.contain_origin("https://glaceon.social/users/monorail", %{ + "deleted" => "2019-10-30T05:48:50.249606Z", + "formerType" => "Note", + "id" => "https://glaceon.social/users/monorail/statuses/103049757364029187", + "type" => "Tombstone" + }) + end + test "contain_origin_from_id() catches obvious spoofing attempts" do data = %{ "id" => "http://example.com/~alyssa/activities/1234.json" From 62f3a93049649dee0ccd7b883887be2fd343fb3e Mon Sep 17 00:00:00 2001 From: Phil Hagelberg Date: Mon, 11 Nov 2019 17:16:44 -0800 Subject: [PATCH 149/154] For remote notices, redirect to the original instead of 404. We shouldn't treat these like local statuses, but I don't think a 404 is the right choice either here, because within pleroma-fe, these are valid URLs. So with remote notices you have the awkward situation where clicking a link will behave differently depending on whether you open it in a new tab or not; the new tab will 404 if it hits static-fe. This new redirecting behavior should improve that situation. --- lib/pleroma/web/static_fe/static_fe_controller.ex | 5 +++++ test/web/static_fe/static_fe_controller_test.exs | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/pleroma/web/static_fe/static_fe_controller.ex b/lib/pleroma/web/static_fe/static_fe_controller.ex index 5e60c82b0..ba44b8a4f 100644 --- a/lib/pleroma/web/static_fe/static_fe_controller.ex +++ b/lib/pleroma/web/static_fe/static_fe_controller.ex @@ -77,6 +77,11 @@ def show(%{assigns: %{notice_id: notice_id}} = conn, _params) do render(conn, "conversation.html", %{activities: timeline, meta: meta}) else + %Activity{object: %Object{data: data}} -> + conn + |> put_status(:found) + |> redirect(external: data["url"] || data["external_url"] || data["id"]) + _ -> conn |> put_status(404) diff --git a/test/web/static_fe/static_fe_controller_test.exs b/test/web/static_fe/static_fe_controller_test.exs index effdfbeb3..b8fb67b22 100644 --- a/test/web/static_fe/static_fe_controller_test.exs +++ b/test/web/static_fe/static_fe_controller_test.exs @@ -151,7 +151,7 @@ test "404 for private status", %{conn: conn} do assert html_response(conn, 404) =~ "not found" end - test "404 for remote cached status", %{conn: conn} do + test "302 for remote cached status", %{conn: conn} do user = insert(:user) message = %{ @@ -175,7 +175,7 @@ test "404 for remote cached status", %{conn: conn} do |> put_req_header("accept", "text/html") |> get("/notice/#{activity.id}") - assert html_response(conn, 404) =~ "not found" + assert html_response(conn, 302) =~ "redirected" end end end From 72cf6a76f4064f226552802b201ba0902084c52a Mon Sep 17 00:00:00 2001 From: Egor Kislitsyn Date: Wed, 13 Nov 2019 18:07:53 +0700 Subject: [PATCH 150/154] Fix random fails of the rate limiter tests --- test/plugs/rate_limiter_test.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/plugs/rate_limiter_test.exs b/test/plugs/rate_limiter_test.exs index bacd621e1..49f63c424 100644 --- a/test/plugs/rate_limiter_test.exs +++ b/test/plugs/rate_limiter_test.exs @@ -25,7 +25,7 @@ test "config is required for plug to work" do test "it restricts based on config values" do limiter_name = :test_opts - scale = 60 + scale = 80 limit = 5 Pleroma.Config.put([:rate_limit, limiter_name], {scale, limit}) From 3350cd8d965f45b51257ab6b9d5073fc81bdaa06 Mon Sep 17 00:00:00 2001 From: Egor Kislitsyn Date: Wed, 13 Nov 2019 18:48:53 +0700 Subject: [PATCH 151/154] Fix formatting in OpenBSD install manual --- docs/installation/openbsd_en.md | 38 +++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/docs/installation/openbsd_en.md b/docs/installation/openbsd_en.md index 3585a326b..45602bd75 100644 --- a/docs/installation/openbsd_en.md +++ b/docs/installation/openbsd_en.md @@ -1,9 +1,13 @@ # Installing on OpenBSD + This guide describes the installation and configuration of pleroma (and the required software to run it) on a single OpenBSD 6.4 server. + For any additional information regarding commands and configuration files mentioned here, check the man pages [online](https://man.openbsd.org/) or directly on your server with the man command. #### Required software + The following packages need to be installed: + * elixir * gmake * ImageMagick @@ -11,8 +15,11 @@ The following packages need to be installed: * postgresql-server * postgresql-contrib -To install them, run the following command (with doas or as root): -`pkg_add elixir gmake ImageMagick git postgresql-server postgresql-contrib` +To install them, run the following command (with doas or as root): + +``` +pkg_add elixir gmake ImageMagick git postgresql-server postgresql-contrib +``` Pleroma requires a reverse proxy, OpenBSD has relayd in base (and is used in this guide) and packages/ports are available for nginx (www/nginx) and apache (www/apache-httpd). Independently of the reverse proxy, [acme-client(1)](https://man.openbsd.org/acme-client) can be used to get a certificate from Let's Encrypt. @@ -31,8 +38,8 @@ Create the \_pleroma user, assign it the pleroma login class and create its home #### Clone pleroma's directory Enter a shell as the \_pleroma user. As root, run `su _pleroma -;cd`. Then clone the repository with `git clone -b stable https://git.pleroma.social/pleroma/pleroma.git`. Pleroma is now installed in /home/\_pleroma/pleroma/, it will be configured and started at the end of this guide. -#### Postgresql -Start a shell as the \_postgresql user (as root run `su _postgresql -` then run the `initdb` command to initialize postgresql: +#### PostgreSQL +Start a shell as the \_postgresql user (as root run `su _postgresql -` then run the `initdb` command to initialize postgresql: If you wish to not use the default location for postgresql's data (/var/postgresql/data), add the following switch at the end of the command: `-D ` and modify the `datadir` variable in the /etc/rc.d/postgresql script. When this is done, enable postgresql so that it starts on boot and start it. As root, run: @@ -44,6 +51,7 @@ To check that it started properly and didn't fail right after starting, you can #### httpd httpd will have three fuctions: + * redirect requests trying to reach the instance over http to the https URL * serve a robots.txt file * get Let's Encrypt certificates, with acme-client @@ -76,9 +84,9 @@ types { include "/usr/share/misc/mime.types" } ``` -Do not forget to change *\* to your server's address(es). If httpd should only listen on one protocol family, comment one of the two first *listen* options. +Do not forget to change ** to your server's address(es). If httpd should only listen on one protocol family, comment one of the two first *listen* options. -Create the /var/www/htdocs/local/ folder and write the content of your robots.txt in /var/www/htdocs/local/robots.txt. +Create the /var/www/htdocs/local/ folder and write the content of your robots.txt in /var/www/htdocs/local/robots.txt. Check the configuration with `httpd -n`, if it is OK enable and start httpd (as root): ``` rcctl enable httpd @@ -86,7 +94,7 @@ rcctl start httpd ``` #### acme-client -acme-client is used to get SSL/TLS certificates from Let's Encrypt. +acme-client is used to get SSL/TLS certificates from Let's Encrypt. Insert the following configuration in /etc/acme-client.conf: ``` # @@ -107,7 +115,7 @@ domain { challengedir "/var/www/acme/" } ``` -Replace *\* by the domain name you'll use for your instance. As root, run `acme-client -n` to check the config, then `acme-client -ADv ` to create account and domain keys, and request a certificate for the first time. +Replace ** by the domain name you'll use for your instance. As root, run `acme-client -n` to check the config, then `acme-client -ADv ` to create account and domain keys, and request a certificate for the first time. Make acme-client run everyday by adding it in /etc/daily.local. As root, run the following command: `echo "acme-client " >> /etc/daily.local`. Relayd will look for certificates and keys based on the address it listens on (see next part), the easiest way to make them available to relayd is to create a link, as root run: @@ -118,7 +126,7 @@ ln -s /etc/ssl/private/.key /etc/ssl/private/.key This will have to be done for each IPv4 and IPv6 address relayd listens on. #### relayd -relayd will be used as the reverse proxy sitting in front of pleroma. +relayd will be used as the reverse proxy sitting in front of pleroma. Insert the following configuration in /etc/relayd.conf: ``` # $OpenBSD: relayd.conf,v 1.4 2018/03/23 09:55:06 claudio Exp $ @@ -169,7 +177,7 @@ relay wwwtls { forward to port 80 check http "/robots.txt" code 200 } ``` -Again, change *\* to your server's address(es) and comment one of the two *listen* options if needed. Also change *wss://CHANGEME.tld* to *wss://\*. +Again, change ** to your server's address(es) and comment one of the two *listen* options if needed. Also change *wss://CHANGEME.tld* to *wss://*. Check the configuration with `relayd -n`, if it is OK enable and start relayd (as root): ``` rcctl enable relayd @@ -177,7 +185,7 @@ rcctl start relayd ``` #### pf -Enabling and configuring pf is highly recommended. +Enabling and configuring pf is highly recommended. In /etc/pf.conf, insert the following configuration: ``` # Macros @@ -202,20 +210,22 @@ pass in quick on $if inet6 proto icmp6 to ($if) icmp6-type { echoreq unreach par pass in quick on $if proto tcp to ($if) port { http https } # relayd/httpd pass in quick on $if proto tcp from $authorized_ssh_clients to ($if) port ssh ``` -Replace *\* by your server's network interface name (which you can get with ifconfig). Consider replacing the content of the authorized\_ssh\_clients macro by, for exemple, your home IP address, to avoid SSH connection attempts from bots. +Replace ** by your server's network interface name (which you can get with ifconfig). Consider replacing the content of the authorized\_ssh\_clients macro by, for exemple, your home IP address, to avoid SSH connection attempts from bots. Check pf's configuration by running `pfctl -nf /etc/pf.conf`, load it with `pfctl -f /etc/pf.conf` and enable pf at boot with `rcctl enable pf`. #### Configure and start pleroma -Enter a shell as \_pleroma (as root `su _pleroma -`) and enter pleroma's installation directory (`cd ~/pleroma/`). +Enter a shell as \_pleroma (as root `su _pleroma -`) and enter pleroma's installation directory (`cd ~/pleroma/`). + Then follow the main installation guide: + * run `mix deps.get` * run `mix pleroma.instance gen` and enter your instance's information when asked * copy config/generated\_config.exs to config/prod.secret.exs. The default values should be sufficient but you should edit it and check that everything seems OK. * exit your current shell back to a root one and run `psql -U postgres -f /home/_pleroma/config/setup_db.psql` to setup the database. * return to a \_pleroma shell into pleroma's installation directory (`su _pleroma -;cd ~/pleroma`) and run `MIX_ENV=prod mix ecto.migrate` -As \_pleroma in /home/\_pleroma/pleroma, you can now run `LC_ALL=en_US.UTF-8 MIX_ENV=prod mix phx.server` to start your instance. +As \_pleroma in /home/\_pleroma/pleroma, you can now run `LC_ALL=en_US.UTF-8 MIX_ENV=prod mix phx.server` to start your instance. In another SSH session/tmux window, check that it is working properly by running `ftp -MVo - http://127.0.0.1:4000/api/v1/instance`, you should get json output. Double-check that *uri*'s value is your instance's domain name. ##### Starting pleroma at boot From 0867cb083eb469ae10cd48d424a51efb2fae4018 Mon Sep 17 00:00:00 2001 From: Phil Hagelberg Date: Tue, 12 Nov 2019 17:19:46 -0800 Subject: [PATCH 152/154] Support redirecting by object ID in static FE. This matches the behavior of pleroma-fe better. Fixes #1412. --- lib/pleroma/web/static_fe/static_fe_controller.ex | 15 +++++++++++++++ test/web/static_fe/static_fe_controller_test.exs | 15 +++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/lib/pleroma/web/static_fe/static_fe_controller.ex b/lib/pleroma/web/static_fe/static_fe_controller.ex index ba44b8a4f..b45d82c2d 100644 --- a/lib/pleroma/web/static_fe/static_fe_controller.ex +++ b/lib/pleroma/web/static_fe/static_fe_controller.ex @@ -119,11 +119,26 @@ def show(%{assigns: %{username_or_id: username_or_id}} = conn, params) do end end + def show(%{assigns: %{object_id: _}} = conn, _params) do + url = Helpers.url(conn) <> conn.request_path + case Activity.get_create_by_object_ap_id_with_object(url) do + %Activity{} = activity -> + redirect(conn, to: "/notice/#{activity.id}") + _ -> + conn + |> put_status(404) + |> render("error.html", %{message: "Post not found.", meta: ""}) + end + end + def assign_id(%{path_info: ["notice", notice_id]} = conn, _opts), do: assign(conn, :notice_id, notice_id) def assign_id(%{path_info: ["users", user_id]} = conn, _opts), do: assign(conn, :username_or_id, user_id) + def assign_id(%{path_info: ["objects", object_id]} = conn, _opts), + do: assign(conn, :object_id, object_id) + def assign_id(conn, _opts), do: conn end diff --git a/test/web/static_fe/static_fe_controller_test.exs b/test/web/static_fe/static_fe_controller_test.exs index b8fb67b22..6ea8cea34 100644 --- a/test/web/static_fe/static_fe_controller_test.exs +++ b/test/web/static_fe/static_fe_controller_test.exs @@ -1,5 +1,6 @@ defmodule Pleroma.Web.StaticFE.StaticFEControllerTest do use Pleroma.Web.ConnCase + alias Pleroma.Activity alias Pleroma.Web.ActivityPub.Transmogrifier alias Pleroma.Web.CommonAPI @@ -128,6 +129,20 @@ test "shows the whole thread", %{conn: conn} do assert html =~ "voyages" end + test "redirect by AP object ID", %{conn: conn} do + user = insert(:user) + + {:ok, %Activity{data: %{"object" => object_url}}} = + CommonAPI.post(user, %{"status" => "beam me up"}) + + conn = + conn + |> put_req_header("accept", "text/html") + |> get(URI.parse(object_url).path) + + assert html_response(conn, 302) =~ "redirected" + end + test "404 when notice not found", %{conn: conn} do conn = conn From 3c60adbc1f773c732458d68b4becaf9bb36d7062 Mon Sep 17 00:00:00 2001 From: Phil Hagelberg Date: Tue, 12 Nov 2019 17:33:54 -0800 Subject: [PATCH 153/154] Support redirecting by activity UUID in static FE as well. --- .../web/static_fe/static_fe_controller.ex | 41 ++++++++++++++----- .../static_fe/static_fe_controller_test.exs | 14 +++++++ 2 files changed, 44 insertions(+), 11 deletions(-) diff --git a/lib/pleroma/web/static_fe/static_fe_controller.ex b/lib/pleroma/web/static_fe/static_fe_controller.ex index b45d82c2d..8ccf15f4b 100644 --- a/lib/pleroma/web/static_fe/static_fe_controller.ex +++ b/lib/pleroma/web/static_fe/static_fe_controller.ex @@ -27,6 +27,12 @@ defp get_title(%Object{data: %{"summary" => summary}}) when is_binary(summary), defp get_title(_), do: nil + defp not_found(conn, message) do + conn + |> put_status(404) + |> render("error.html", %{message: message, meta: ""}) + end + def get_counts(%Activity{} = activity) do %Object{data: data} = Object.normalize(activity) @@ -83,9 +89,7 @@ def show(%{assigns: %{notice_id: notice_id}} = conn, _params) do |> redirect(external: data["url"] || data["external_url"] || data["id"]) _ -> - conn - |> put_status(404) - |> render("error.html", %{message: "Post not found.", meta: ""}) + not_found(conn, "Post not found.") end end @@ -113,21 +117,33 @@ def show(%{assigns: %{username_or_id: username_or_id}} = conn, params) do }) _ -> - conn - |> put_status(404) - |> render("error.html", %{message: "User not found.", meta: ""}) + not_found(conn, "User not found.") end end def show(%{assigns: %{object_id: _}} = conn, _params) do url = Helpers.url(conn) <> conn.request_path + case Activity.get_create_by_object_ap_id_with_object(url) do %Activity{} = activity -> - redirect(conn, to: "/notice/#{activity.id}") - _ -> - conn - |> put_status(404) - |> render("error.html", %{message: "Post not found.", meta: ""}) + to = Helpers.o_status_path(Pleroma.Web.Endpoint, :notice, activity) + redirect(conn, to: to) + + _ -> + not_found(conn, "Post not found.") + end + end + + def show(%{assigns: %{activity_id: _}} = conn, _params) do + url = Helpers.url(conn) <> conn.request_path + + case Activity.get_by_ap_id(url) do + %Activity{} = activity -> + to = Helpers.o_status_path(Pleroma.Web.Endpoint, :notice, activity) + redirect(conn, to: to) + + _ -> + not_found(conn, "Post not found.") end end @@ -140,5 +156,8 @@ def assign_id(%{path_info: ["users", user_id]} = conn, _opts), def assign_id(%{path_info: ["objects", object_id]} = conn, _opts), do: assign(conn, :object_id, object_id) + def assign_id(%{path_info: ["activities", activity_id]} = conn, _opts), + do: assign(conn, :activity_id, activity_id) + def assign_id(conn, _opts), do: conn end diff --git a/test/web/static_fe/static_fe_controller_test.exs b/test/web/static_fe/static_fe_controller_test.exs index 6ea8cea34..2ce8f9fa3 100644 --- a/test/web/static_fe/static_fe_controller_test.exs +++ b/test/web/static_fe/static_fe_controller_test.exs @@ -143,6 +143,20 @@ test "redirect by AP object ID", %{conn: conn} do assert html_response(conn, 302) =~ "redirected" end + test "redirect by activity ID", %{conn: conn} do + user = insert(:user) + + {:ok, %Activity{data: %{"id" => id}}} = + CommonAPI.post(user, %{"status" => "I'm a doctor, not a devops!"}) + + conn = + conn + |> put_req_header("accept", "text/html") + |> get(URI.parse(id).path) + + assert html_response(conn, 302) =~ "redirected" + end + test "404 when notice not found", %{conn: conn} do conn = conn From 7a322713c33e8ef2fdc326f9e35d1fcbe7590c93 Mon Sep 17 00:00:00 2001 From: lain Date: Thu, 14 Nov 2019 08:21:06 +0000 Subject: [PATCH 154/154] Update CHANGELOG.md --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c9b447d09..0464f4571 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -59,7 +59,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Pleroma API: `POST /api/v1/pleroma/conversations/read` to mark all conversations as read - Mastodon API: Add `/api/v1/markers` for managing timeline read markers - Mastodon API: Add the `recipients` parameter to `GET /api/v1/conversations` -- Pleroma API: Add Emoji reactions - Configuration: `feed` option for user atom feed. - Pleroma API: Add Emoji reactions