diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/user.ex | 12 | ||||
-rw-r--r-- | lib/pleroma/web/common_api/common_api.ex | 3 | ||||
-rw-r--r-- | lib/pleroma/web/mastodon_api/mastodon_api_controller.ex | 3 | ||||
-rw-r--r-- | lib/pleroma/web/mastodon_api/views/status_view.ex | 2 | ||||
-rw-r--r-- | lib/pleroma/web/ostatus/activity_representer.ex | 8 |
5 files changed, 16 insertions, 12 deletions
diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index fbeeef003..68ffe184b 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -61,8 +61,9 @@ defmodule Pleroma.User do end def user_info(%User{} = user) do + oneself = if user.local, do: 1, else: 0 %{ - following_count: length(user.following), + following_count: length(user.following) - oneself, note_count: user.info["note_count"] || 0, follower_count: user.info["follower_count"] || 0 } @@ -166,7 +167,7 @@ defmodule Pleroma.User do def unfollow(%User{} = follower, %User{} = followed) do ap_followers = followed.follower_address - if following?(follower, followed) do + if following?(follower, followed) and follower.ap_id != followed.ap_id do following = follower.following |> List.delete(ap_followers) @@ -264,6 +265,7 @@ defmodule Pleroma.User do def update_follower_count(%User{} = user) do follower_count_query = from u in User, where: fragment("? @> ?", u.following, ^user.follower_address), + where: u.id != ^user.id, select: count(u.id) follower_count = Repo.one(follower_count_query) @@ -285,12 +287,12 @@ defmodule Pleroma.User do def get_recipients_from_activity(%Activity{data: %{"to" => to}}) do query = from u in User, - where: u.local == true - - query = from u in query, where: u.ap_id in ^to, or_where: fragment("? \\\?| ?", u.following, ^to) + query = from u in query, + where: u.local == true + Repo.all(query) end diff --git a/lib/pleroma/web/common_api/common_api.ex b/lib/pleroma/web/common_api/common_api.ex index 9bc7f2ce6..dc94e5377 100644 --- a/lib/pleroma/web/common_api/common_api.ex +++ b/lib/pleroma/web/common_api/common_api.ex @@ -59,7 +59,8 @@ defmodule Pleroma.Web.CommonAPI do content_html <- make_content_html(status, mentions, attachments, tags), context <- make_context(inReplyTo), cw <- data["spoiler_text"], - object <- make_note_data(user.ap_id, to, context, content_html, attachments, inReplyTo, tags, cw) do + object <- make_note_data(user.ap_id, to, context, content_html, attachments, inReplyTo, tags, cw), + object <- Map.put(object, "emoji", Formatter.get_emoji(status) |> Enum.reduce(%{}, fn({name, file}, acc) -> Map.put(acc, name, "#{Pleroma.Web.Endpoint.static_url}#{file}") end)) do res = ActivityPub.create(to, user, context, object) User.increase_note_count(user) res diff --git a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex index 9c50e850b..fc7f21096 100644 --- a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex +++ b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex @@ -106,7 +106,8 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do user_count: 1, status_count: 2, domain_count: 3 - } + }, + max_toot_chars: Keyword.get(@instance, :limit) } json(conn, response) diff --git a/lib/pleroma/web/mastodon_api/views/status_view.ex b/lib/pleroma/web/mastodon_api/views/status_view.ex index 38abdb35f..5585a5605 100644 --- a/lib/pleroma/web/mastodon_api/views/status_view.ex +++ b/lib/pleroma/web/mastodon_api/views/status_view.ex @@ -96,7 +96,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do sensitive: sensitive, spoiler_text: object["summary"] || "", visibility: "public", - media_attachments: attachments, + media_attachments: attachments |> Enum.take(4), mentions: mentions, tags: [], # fix, application: %{ diff --git a/lib/pleroma/web/ostatus/activity_representer.ex b/lib/pleroma/web/ostatus/activity_representer.ex index cfc342fca..aa2b1df39 100644 --- a/lib/pleroma/web/ostatus/activity_representer.ex +++ b/lib/pleroma/web/ostatus/activity_representer.ex @@ -56,9 +56,9 @@ defmodule Pleroma.Web.OStatus.ActivityRepresenter do defp get_links(_activity), do: [] - defp get_emoji_links(content) do - Enum.map(Formatter.get_emoji(content), fn({emoji, file}) -> - {:link, [name: to_charlist(emoji), rel: 'emoji', href: to_charlist("#{Pleroma.Web.Endpoint.static_url}#{file}")], []} + defp get_emoji_links(emojis) do + Enum.map(emojis, fn({emoji, file}) -> + {:link, [name: to_charlist(emoji), rel: 'emoji', href: to_charlist(file)], []} end) end @@ -81,7 +81,7 @@ defmodule Pleroma.Web.OStatus.ActivityRepresenter do categories = (activity.data["object"]["tag"] || []) |> Enum.map(fn (tag) -> {:category, [term: to_charlist(tag)], []} end) - emoji_links = get_emoji_links(activity.data["object"]["content"] || "") + emoji_links = get_emoji_links(activity.data["object"]["emoji"] || %{}) summary = if activity.data["object"]["summary"] do [{:summary, [], h.(activity.data["object"]["summary"])}] |