diff --git a/lib/pleroma/formatter.ex b/lib/pleroma/formatter.ex
index 8b736797b..fdf91f56e 100644
--- a/lib/pleroma/formatter.ex
+++ b/lib/pleroma/formatter.ex
@@ -104,13 +104,19 @@ def html_escape(text) do
{finmoji, "/finmoji/128px/#{finmoji}-128.png"}
end)
- @emoji_from_file (with {:ok, file} <- File.read("config/emoji.txt") do
- file
- |> String.trim
- |> String.split("\n")
- |> Enum.map(fn(line) ->
- [name, file] = String.split(line, ", ")
- {name, file}
+ @emoji_from_file (with {:ok, default} <- File.read("config/emoji.txt") do
+ custom =
+ with {:ok, custom} <- File.read("config/custom_emoji.txt") do
+ custom
+ else
+ _e -> ""
+ end
+ (default <> "\n" <> custom)
+ |> String.trim()
+ |> String.split(~r/\n+/)
+ |> Enum.map(fn(line) ->
+ [name, file] = String.split(line, ~r/,\s*/)
+ {name, file}
end)
else
_ -> []
diff --git a/lib/pleroma/web/endpoint.ex b/lib/pleroma/web/endpoint.ex
index b57cf3917..725d2ee64 100644
--- a/lib/pleroma/web/endpoint.ex
+++ b/lib/pleroma/web/endpoint.ex
@@ -12,7 +12,7 @@ defmodule Pleroma.Web.Endpoint do
at: "/media", from: "uploads", gzip: false
plug Plug.Static,
at: "/", from: :pleroma,
- only: ~w(index.html static finmoji emoji packs sounds sw.js)
+ only: ~w(index.html static finmoji emoji packs sounds instance sw.js)
# Code reloading can be explicitly enabled under the
# :code_reloader configuration of your endpoint.
diff --git a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
index 0615ac11a..e16a2a092 100644
--- a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
+++ b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
@@ -103,6 +103,7 @@ def masto_instance(conn, _params) do
streaming_api: String.replace(Web.base_url, ["http","https"], "wss")
},
stats: Stats.get_stats,
+ thumbnail: Web.base_url <> "/instance/thumbnail.jpeg",
max_toot_chars: Keyword.get(@instance, :limit)
}
diff --git a/lib/pleroma/web/router.ex b/lib/pleroma/web/router.ex
index 63dbd6245..6e9f40955 100644
--- a/lib/pleroma/web/router.ex
+++ b/lib/pleroma/web/router.ex
@@ -62,6 +62,7 @@ def user_fetcher(username) do
pipe_through :pleroma_html
get "/ostatus_subscribe", UtilController, :remote_follow
post "/ostatus_subscribe", UtilController, :do_remote_follow
+ post "/main/ostatus", UtilController, :remote_subscribe
end
scope "/api/pleroma", Pleroma.Web.TwitterAPI do
diff --git a/lib/pleroma/web/templates/twitter_api/util/subscribe.html.eex b/lib/pleroma/web/templates/twitter_api/util/subscribe.html.eex
new file mode 100644
index 000000000..f60accebf
--- /dev/null
+++ b/lib/pleroma/web/templates/twitter_api/util/subscribe.html.eex
@@ -0,0 +1,10 @@
+<%= if @error do %>
+
Error: <%= @error %>
+<% else %>
+ Remotely follow <%= @nickname %>
+ <%= form_for @conn, util_path(@conn, :remote_subscribe), [as: "user"], fn f -> %>
+ <%= hidden_input f, :nickname, value: @nickname %>
+ <%= text_input f, :profile, placeholder: "Your account ID, e.g. lain@quitter.se" %>
+ <%= submit "Follow" %>
+ <% end %>
+<% end %>
diff --git a/lib/pleroma/web/twitter_api/controllers/util_controller.ex b/lib/pleroma/web/twitter_api/controllers/util_controller.ex
index a1d56e3ab..0b7c64015 100644
--- a/lib/pleroma/web/twitter_api/controllers/util_controller.ex
+++ b/lib/pleroma/web/twitter_api/controllers/util_controller.ex
@@ -3,6 +3,7 @@ defmodule Pleroma.Web.TwitterAPI.UtilController do
require Logger
alias Pleroma.Web
alias Pleroma.Web.OStatus
+ alias Pleroma.Web.WebFinger
alias Comeonin.Pbkdf2
alias Pleroma.Formatter
alias Pleroma.Web.ActivityPub.ActivityPub
@@ -32,6 +33,26 @@ def help_test(conn, _params) do
json(conn, "ok")
end
+ def remote_subscribe(conn, %{"nickname" => nick, "profile" => _}) do
+ with %User{} = user <- User.get_cached_by_nickname(nick),
+ avatar = User.avatar_url(user) do
+ conn
+ |> render("subscribe.html", %{nickname: nick, avatar: avatar, error: false})
+ else
+ _e -> render(conn, "subscribe.html", %{nickname: nick, avatar: nil, error: "Could not find user"})
+ end
+ end
+ def remote_subscribe(conn, %{"user" => %{"nickname" => nick, "profile" => profile}}) do
+ with {:ok, %{"subscribe_address" => template}} <- WebFinger.finger(profile),
+ %User{ap_id: ap_id} <- User.get_cached_by_nickname(nick) do
+ conn
+ |> Phoenix.Controller.redirect(external: String.replace(template, "{uri}", ap_id))
+ else
+ _e ->
+ render(conn, "subscribe.html", %{nickname: nick, avatar: nil, error: "Something went wrong."})
+ end
+ end
+
def remote_follow(%{assigns: %{user: user}} = conn, %{"acct" => acct}) do
{err, followee} = OStatus.find_or_make_user(acct)
avatar = User.avatar_url(followee)
diff --git a/lib/pleroma/web/twitter_api/views/user_view.ex b/lib/pleroma/web/twitter_api/views/user_view.ex
index 1b995f42f..f49bcc0fb 100644
--- a/lib/pleroma/web/twitter_api/views/user_view.ex
+++ b/lib/pleroma/web/twitter_api/views/user_view.ex
@@ -47,6 +47,7 @@ def render("user.json", %{user: user = %User{}} = assigns) do
"statusnet_profile_url" => user.ap_id,
"cover_photo" => User.banner_url(user) |> MediaProxy.url(),
"background_image" => image_url(user.info["background"]) |> MediaProxy.url(),
+ "is_local" => user.local
}
if assigns[:token] do
diff --git a/lib/pleroma/web/web_finger/web_finger.ex b/lib/pleroma/web/web_finger/web_finger.ex
index 4ae3eab59..95e717b17 100644
--- a/lib/pleroma/web/web_finger/web_finger.ex
+++ b/lib/pleroma/web/web_finger/web_finger.ex
@@ -69,11 +69,13 @@ defp webfinger_from_xml(doc) do
topic = XML.string_from_xpath(~s{//Link[@rel="http://schemas.google.com/g/2010#updates-from"]/@href}, doc)
subject = XML.string_from_xpath("//Subject", doc)
salmon = XML.string_from_xpath(~s{//Link[@rel="salmon"]/@href}, doc)
+ subscribe_address = XML.string_from_xpath(~s{//Link[@rel="http://ostatus.org/schema/1.0/subscribe"]/@template}, doc)
data = %{
"magic_key" => magic_key,
"topic" => topic,
"subject" => subject,
- "salmon" => salmon
+ "salmon" => salmon,
+ "subscribe_address" => subscribe_address
}
{:ok, data}
end
diff --git a/priv/static/instance/thumbnail.jpeg b/priv/static/instance/thumbnail.jpeg
new file mode 100644
index 000000000..b7e012644
Binary files /dev/null and b/priv/static/instance/thumbnail.jpeg differ
diff --git a/test/web/ostatus/ostatus_test.exs b/test/web/ostatus/ostatus_test.exs
index de01612b3..b27f8cb55 100644
--- a/test/web/ostatus/ostatus_test.exs
+++ b/test/web/ostatus/ostatus_test.exs
@@ -302,7 +302,8 @@ test "it returns user info in a hash" do
"host" => "social.heldscal.la",
"fqn" => user,
"bio" => "cofe",
- "avatar" => %{"type" => "Image", "url" => [%{"href" => "https://social.heldscal.la/avatar/29191-original-20170421154949.jpeg", "mediaType" => "image/jpeg", "type" => "Link"}]}
+ "avatar" => %{"type" => "Image", "url" => [%{"href" => "https://social.heldscal.la/avatar/29191-original-20170421154949.jpeg", "mediaType" => "image/jpeg", "type" => "Link"}]},
+ "subscribe_address" => "https://social.heldscal.la/main/ostatussub?profile={uri}"
}
assert data == expected
end
@@ -325,7 +326,8 @@ test "it works with the uri" do
"host" => "social.heldscal.la",
"fqn" => user,
"bio" => "cofe",
- "avatar" => %{"type" => "Image", "url" => [%{"href" => "https://social.heldscal.la/avatar/29191-original-20170421154949.jpeg", "mediaType" => "image/jpeg", "type" => "Link"}]}
+ "avatar" => %{"type" => "Image", "url" => [%{"href" => "https://social.heldscal.la/avatar/29191-original-20170421154949.jpeg", "mediaType" => "image/jpeg", "type" => "Link"}]},
+ "subscribe_address" => "https://social.heldscal.la/main/ostatussub?profile={uri}"
}
assert data == expected
end
diff --git a/test/web/twitter_api/views/user_view_test.exs b/test/web/twitter_api/views/user_view_test.exs
index 3f84e4116..e68230a86 100644
--- a/test/web/twitter_api/views/user_view_test.exs
+++ b/test/web/twitter_api/views/user_view_test.exs
@@ -56,7 +56,8 @@ test "A user" do
"rights" => %{},
"statusnet_profile_url" => user.ap_id,
"cover_photo" => banner,
- "background_image" => nil
+ "background_image" => nil,
+ "is_local" => true
}
assert represented == UserView.render("show.json", %{user: user})
@@ -88,7 +89,8 @@ test "A user for a given other follower", %{user: user} do
"rights" => %{},
"statusnet_profile_url" => user.ap_id,
"cover_photo" => banner,
- "background_image" => nil
+ "background_image" => nil,
+ "is_local" => true
}
assert represented == UserView.render("show.json", %{user: user, for: follower})
@@ -121,7 +123,8 @@ test "A user that follows you", %{user: user} do
"rights" => %{},
"statusnet_profile_url" => follower.ap_id,
"cover_photo" => banner,
- "background_image" => nil
+ "background_image" => nil,
+ "is_local" => true
}
assert represented == UserView.render("show.json", %{user: follower, for: user})
@@ -154,7 +157,8 @@ test "A blocked user for the blocker", %{user: user} do
"rights" => %{},
"statusnet_profile_url" => user.ap_id,
"cover_photo" => banner,
- "background_image" => nil
+ "background_image" => nil,
+ "is_local" => true
}
blocker = Repo.get(User, blocker.id)