summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/html.ex2
-rw-r--r--lib/pleroma/user/info.ex6
-rw-r--r--lib/pleroma/web/activity_pub/transmogrifier.ex2
-rw-r--r--lib/pleroma/web/activity_pub/views/user_view.ex8
-rw-r--r--lib/pleroma/web/mastodon_api/mastodon_api_controller.ex4
-rw-r--r--lib/pleroma/web/mastodon_api/views/status_view.ex8
-rw-r--r--lib/pleroma/web/twitter_api/twitter_api_controller.ex6
-rw-r--r--lib/pleroma/web/twitter_api/views/user_view.ex3
8 files changed, 25 insertions, 14 deletions
diff --git a/lib/pleroma/html.ex b/lib/pleroma/html.ex
index bf5daa948..b4a4742ee 100644
--- a/lib/pleroma/html.ex
+++ b/lib/pleroma/html.ex
@@ -59,6 +59,8 @@ defmodule Pleroma.HTML do
end)
end
+ def extract_first_external_url(_, nil), do: {:error, "No content"}
+
def extract_first_external_url(object, content) do
key = "URL|#{object.id}"
diff --git a/lib/pleroma/user/info.ex b/lib/pleroma/user/info.ex
index c6c923aac..2186190a0 100644
--- a/lib/pleroma/user/info.ex
+++ b/lib/pleroma/user/info.ex
@@ -30,7 +30,8 @@ defmodule Pleroma.User.Info do
field(:topic, :string, default: nil)
field(:hub, :string, default: nil)
field(:salmon, :string, default: nil)
- field(:hide_network, :boolean, default: false)
+ field(:hide_followers, :boolean, default: false)
+ field(:hide_followings, :boolean, default: false)
field(:pinned_activities, {:array, :string}, default: [])
# Found in the wild
@@ -143,7 +144,8 @@ defmodule Pleroma.User.Info do
:no_rich_text,
:default_scope,
:banner,
- :hide_network,
+ :hide_followings,
+ :hide_followers,
:background
])
end
diff --git a/lib/pleroma/web/activity_pub/transmogrifier.ex b/lib/pleroma/web/activity_pub/transmogrifier.ex
index 43725c3db..7151efdeb 100644
--- a/lib/pleroma/web/activity_pub/transmogrifier.ex
+++ b/lib/pleroma/web/activity_pub/transmogrifier.ex
@@ -313,6 +313,8 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
|> Map.put("tag", combined)
end
+ def fix_tag(%{"tag" => %{} = tag} = object), do: Map.put(object, "tag", [tag])
+
def fix_tag(object), do: object
# content map usually only has one language so this will do for now.
diff --git a/lib/pleroma/web/activity_pub/views/user_view.ex b/lib/pleroma/web/activity_pub/views/user_view.ex
index dcf681b6d..b9588bee5 100644
--- a/lib/pleroma/web/activity_pub/views/user_view.ex
+++ b/lib/pleroma/web/activity_pub/views/user_view.ex
@@ -86,7 +86,7 @@ defmodule Pleroma.Web.ActivityPub.UserView do
query = from(user in query, select: [:ap_id])
following = Repo.all(query)
- collection(following, "#{user.ap_id}/following", page, !user.info.hide_network)
+ collection(following, "#{user.ap_id}/following", page, !user.info.hide_followings)
|> Map.merge(Utils.make_json_ld_header())
end
@@ -99,7 +99,7 @@ defmodule Pleroma.Web.ActivityPub.UserView do
"id" => "#{user.ap_id}/following",
"type" => "OrderedCollection",
"totalItems" => length(following),
- "first" => collection(following, "#{user.ap_id}/following", 1, !user.info.hide_network)
+ "first" => collection(following, "#{user.ap_id}/following", 1, !user.info.hide_followings)
}
|> Map.merge(Utils.make_json_ld_header())
end
@@ -109,7 +109,7 @@ defmodule Pleroma.Web.ActivityPub.UserView do
query = from(user in query, select: [:ap_id])
followers = Repo.all(query)
- collection(followers, "#{user.ap_id}/followers", page, !user.info.hide_network)
+ collection(followers, "#{user.ap_id}/followers", page, !user.info.hide_followers)
|> Map.merge(Utils.make_json_ld_header())
end
@@ -122,7 +122,7 @@ defmodule Pleroma.Web.ActivityPub.UserView do
"id" => "#{user.ap_id}/followers",
"type" => "OrderedCollection",
"totalItems" => length(followers),
- "first" => collection(followers, "#{user.ap_id}/followers", 1, !user.info.hide_network)
+ "first" => collection(followers, "#{user.ap_id}/followers", 1, !user.info.hide_followers)
}
|> Map.merge(Utils.make_json_ld_header())
end
diff --git a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
index 7f3fbff4a..85769c3d7 100644
--- a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
+++ b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
@@ -605,7 +605,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
followers =
cond do
for_user && user.id == for_user.id -> followers
- user.info.hide_network -> []
+ user.info.hide_followers -> []
true -> followers
end
@@ -621,7 +621,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
followers =
cond do
for_user && user.id == for_user.id -> followers
- user.info.hide_network -> []
+ user.info.hide_followings -> []
true -> followers
end
diff --git a/lib/pleroma/web/mastodon_api/views/status_view.ex b/lib/pleroma/web/mastodon_api/views/status_view.ex
index d1b11d4f1..c0e289ef8 100644
--- a/lib/pleroma/web/mastodon_api/views/status_view.ex
+++ b/lib/pleroma/web/mastodon_api/views/status_view.ex
@@ -192,8 +192,12 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
page_url = page_url_data |> to_string
image_url =
- URI.merge(page_url_data, URI.parse(rich_media[:image]))
- |> to_string
+ if rich_media[:image] != nil do
+ URI.merge(page_url_data, URI.parse(rich_media[:image]))
+ |> to_string
+ else
+ nil
+ end
site_name = rich_media[:site_name] || page_url_data.host
diff --git a/lib/pleroma/web/twitter_api/twitter_api_controller.ex b/lib/pleroma/web/twitter_api/twitter_api_controller.ex
index 3064d61ea..5e3fe9352 100644
--- a/lib/pleroma/web/twitter_api/twitter_api_controller.ex
+++ b/lib/pleroma/web/twitter_api/twitter_api_controller.ex
@@ -503,7 +503,7 @@ defmodule Pleroma.Web.TwitterAPI.Controller do
followers =
cond do
for_user && user.id == for_user.id -> followers
- user.info.hide_network -> []
+ user.info.hide_followers -> []
true -> followers
end
@@ -523,7 +523,7 @@ defmodule Pleroma.Web.TwitterAPI.Controller do
friends =
cond do
for_user && user.id == for_user.id -> friends
- user.info.hide_network -> []
+ user.info.hide_followings -> []
true -> friends
end
@@ -618,7 +618,7 @@ defmodule Pleroma.Web.TwitterAPI.Controller do
defp build_info_cng(user, params) do
info_params =
- ["no_rich_text", "locked", "hide_network"]
+ ["no_rich_text", "locked", "hide_followers", "hide_followings"]
|> Enum.reduce(%{}, fn key, res ->
if value = params[key] do
Map.put(res, key, value == "true")
diff --git a/lib/pleroma/web/twitter_api/views/user_view.ex b/lib/pleroma/web/twitter_api/views/user_view.ex
index 15682db8f..cd7c4349c 100644
--- a/lib/pleroma/web/twitter_api/views/user_view.ex
+++ b/lib/pleroma/web/twitter_api/views/user_view.ex
@@ -108,7 +108,8 @@ defmodule Pleroma.Web.TwitterAPI.UserView do
"locked" => user.info.locked,
"default_scope" => user.info.default_scope,
"no_rich_text" => user.info.no_rich_text,
- "hide_network" => user.info.hide_network,
+ "hide_followers" => user.info.hide_followers,
+ "hide_followings" => user.info.hide_followings,
"fields" => fields,
# Pleroma extension