1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.ActivityPub.Transmogrifier do
7 A module to handle coding from internal to wire ActivityPub and back.
11 alias Pleroma.Object.Containment
14 alias Pleroma.Web.ActivityPub.ActivityPub
15 alias Pleroma.Web.ActivityPub.Utils
16 alias Pleroma.Web.ActivityPub.Visibility
17 alias Pleroma.Web.Federator
22 require Pleroma.Constants
25 Modifies an incoming AP object (mastodon format) to our internal format.
27 def fix_object(object, options \\ []) do
29 |> strip_internal_fields
34 |> fix_in_reply_to(options)
43 def fix_summary(%{"summary" => nil} = object) do
45 |> Map.put("summary", "")
48 def fix_summary(%{"summary" => _} = object) do
49 # summary is present, nothing to do
53 def fix_summary(object) do
55 |> Map.put("summary", "")
58 def fix_addressing_list(map, field) do
60 is_binary(map[field]) ->
61 Map.put(map, field, [map[field]])
64 Map.put(map, field, [])
71 def fix_explicit_addressing(
72 %{"to" => to, "cc" => cc} = object,
78 |> Enum.filter(fn x -> x in explicit_mentions end)
82 |> Enum.filter(fn x -> x not in explicit_mentions end)
86 |> Enum.reject(fn x -> String.ends_with?(x, "/followers") and x != follower_collection end)
90 |> Map.put("to", explicit_to)
91 |> Map.put("cc", final_cc)
94 def fix_explicit_addressing(object, _explicit_mentions, _followers_collection), do: object
96 # if directMessage flag is set to true, leave the addressing alone
97 def fix_explicit_addressing(%{"directMessage" => true} = object), do: object
99 def fix_explicit_addressing(object) do
102 |> Utils.determine_explicit_mentions()
104 follower_collection = User.get_cached_by_ap_id(Containment.get_actor(object)).follower_address
106 explicit_mentions = explicit_mentions ++ [Pleroma.Constants.as_public(), follower_collection]
108 fix_explicit_addressing(object, explicit_mentions, follower_collection)
111 # if as:Public is addressed, then make sure the followers collection is also addressed
112 # so that the activities will be delivered to local users.
113 def fix_implicit_addressing(%{"to" => to, "cc" => cc} = object, followers_collection) do
114 recipients = to ++ cc
116 if followers_collection not in recipients do
118 Pleroma.Constants.as_public() in cc ->
119 to = to ++ [followers_collection]
120 Map.put(object, "to", to)
122 Pleroma.Constants.as_public() in to ->
123 cc = cc ++ [followers_collection]
124 Map.put(object, "cc", cc)
134 def fix_implicit_addressing(object, _), do: object
136 def fix_addressing(object) do
137 {:ok, %User{} = user} = User.get_or_fetch_by_ap_id(object["actor"])
138 followers_collection = User.ap_followers(user)
141 |> fix_addressing_list("to")
142 |> fix_addressing_list("cc")
143 |> fix_addressing_list("bto")
144 |> fix_addressing_list("bcc")
145 |> fix_explicit_addressing()
146 |> fix_implicit_addressing(followers_collection)
149 def fix_actor(%{"attributedTo" => actor} = object) do
151 |> Map.put("actor", Containment.get_actor(%{"actor" => actor}))
154 def fix_in_reply_to(object, options \\ [])
156 def fix_in_reply_to(%{"inReplyTo" => in_reply_to} = object, options)
157 when not is_nil(in_reply_to) do
160 is_bitstring(in_reply_to) ->
163 is_map(in_reply_to) && is_bitstring(in_reply_to["id"]) ->
166 is_list(in_reply_to) && is_bitstring(Enum.at(in_reply_to, 0)) ->
167 Enum.at(in_reply_to, 0)
169 # Maybe I should output an error too?
174 object = Map.put(object, "inReplyToAtomUri", in_reply_to_id)
176 if Federator.allowed_incoming_reply_depth?(options[:depth]) do
177 case get_obj_helper(in_reply_to_id, options) do
178 {:ok, replied_object} ->
179 with %Activity{} = _activity <-
180 Activity.get_create_by_object_ap_id(replied_object.data["id"]) do
182 |> Map.put("inReplyTo", replied_object.data["id"])
183 |> Map.put("inReplyToAtomUri", object["inReplyToAtomUri"] || in_reply_to_id)
184 |> Map.put("conversation", replied_object.data["context"] || object["conversation"])
185 |> Map.put("context", replied_object.data["context"] || object["conversation"])
188 Logger.error("Couldn't fetch \"#{inspect(in_reply_to_id)}\", error: #{inspect(e)}")
193 Logger.error("Couldn't fetch \"#{inspect(in_reply_to_id)}\", error: #{inspect(e)}")
201 def fix_in_reply_to(object, _options), do: object
203 def fix_context(object) do
204 context = object["context"] || object["conversation"] || Utils.generate_context_id()
207 |> Map.put("context", context)
208 |> Map.put("conversation", context)
211 def fix_attachments(%{"attachment" => attachment} = object) when is_list(attachment) do
214 |> Enum.map(fn data ->
215 media_type = data["mediaType"] || data["mimeType"]
216 href = data["url"] || data["href"]
218 url = [%{"type" => "Link", "mediaType" => media_type, "href" => href}]
221 |> Map.put("mediaType", media_type)
222 |> Map.put("url", url)
226 |> Map.put("attachment", attachments)
229 def fix_attachments(%{"attachment" => attachment} = object) when is_map(attachment) do
230 Map.put(object, "attachment", [attachment])
234 def fix_attachments(object), do: object
236 def fix_url(%{"url" => url} = object) when is_map(url) do
238 |> Map.put("url", url["href"])
241 def fix_url(%{"type" => "Video", "url" => url} = object) when is_list(url) do
242 first_element = Enum.at(url, 0)
246 |> Enum.filter(fn x -> is_map(x) end)
247 |> Enum.filter(fn x -> x["mimeType"] == "text/html" end)
251 |> Map.put("attachment", [first_element])
252 |> Map.put("url", link_element["href"])
255 def fix_url(%{"type" => object_type, "url" => url} = object)
256 when object_type != "Video" and is_list(url) do
257 first_element = Enum.at(url, 0)
261 is_bitstring(first_element) -> first_element
262 is_map(first_element) -> first_element["href"] || ""
267 |> Map.put("url", url_string)
270 def fix_url(object), do: object
272 def fix_emoji(%{"tag" => tags} = object) when is_list(tags) do
273 emoji = tags |> Enum.filter(fn data -> data["type"] == "Emoji" and data["icon"] end)
277 |> Enum.reduce(%{}, fn data, mapping ->
278 name = String.trim(data["name"], ":")
280 mapping |> Map.put(name, data["icon"]["url"])
283 # we merge mastodon and pleroma emoji into a single mapping, to allow for both wire formats
284 emoji = Map.merge(object["emoji"] || %{}, emoji)
287 |> Map.put("emoji", emoji)
290 def fix_emoji(%{"tag" => %{"type" => "Emoji"} = tag} = object) do
291 name = String.trim(tag["name"], ":")
292 emoji = %{name => tag["icon"]["url"]}
295 |> Map.put("emoji", emoji)
298 def fix_emoji(object), do: object
300 def fix_tag(%{"tag" => tag} = object) when is_list(tag) do
303 |> Enum.filter(fn data -> data["type"] == "Hashtag" and data["name"] end)
304 |> Enum.map(fn data -> String.slice(data["name"], 1..-1) end)
306 combined = tag ++ tags
309 |> Map.put("tag", combined)
312 def fix_tag(%{"tag" => %{"type" => "Hashtag", "name" => hashtag} = tag} = object) do
313 combined = [tag, String.slice(hashtag, 1..-1)]
316 |> Map.put("tag", combined)
319 def fix_tag(%{"tag" => %{} = tag} = object), do: Map.put(object, "tag", [tag])
321 def fix_tag(object), do: object
323 # content map usually only has one language so this will do for now.
324 def fix_content_map(%{"contentMap" => content_map} = object) do
325 content_groups = Map.to_list(content_map)
326 {_, content} = Enum.at(content_groups, 0)
329 |> Map.put("content", content)
332 def fix_content_map(object), do: object
334 def fix_type(object, options \\ [])
336 def fix_type(%{"inReplyTo" => reply_id, "name" => _} = object, options)
337 when is_binary(reply_id) do
339 with true <- Federator.allowed_incoming_reply_depth?(options[:depth]),
340 {:ok, object} <- get_obj_helper(reply_id, options) do
344 if reply && reply.data["type"] == "Question" do
345 Map.put(object, "type", "Answer")
351 def fix_type(object, _), do: object
353 defp mastodon_follow_hack(%{"id" => id, "actor" => follower_id}, followed) do
354 with true <- id =~ "follows",
355 %User{local: true} = follower <- User.get_cached_by_ap_id(follower_id),
356 %Activity{} = activity <- Utils.fetch_latest_follow(follower, followed) do
363 defp mastodon_follow_hack(_, _), do: {:error, nil}
365 defp get_follow_activity(follow_object, followed) do
366 with object_id when not is_nil(object_id) <- Utils.get_ap_id(follow_object),
367 {_, %Activity{} = activity} <- {:activity, Activity.get_by_ap_id(object_id)} do
370 # Can't find the activity. This might a Mastodon 2.3 "Accept"
372 mastodon_follow_hack(follow_object, followed)
379 def handle_incoming(data, options \\ [])
381 # Flag objects are placed ahead of the ID check because Mastodon 2.8 and earlier send them
383 def handle_incoming(%{"type" => "Flag", "object" => objects, "actor" => actor} = data, _options) do
384 with context <- data["context"] || Utils.generate_context_id(),
385 content <- data["content"] || "",
386 %User{} = actor <- User.get_cached_by_ap_id(actor),
388 # Reduce the object list to find the reported user.
390 Enum.reduce_while(objects, nil, fn ap_id, _ ->
391 with %User{} = user <- User.get_cached_by_ap_id(ap_id) do
398 # Remove the reported user from the object list.
399 statuses <- Enum.filter(objects, fn ap_id -> ap_id != account.ap_id end) do
407 "cc" => [account.ap_id]
411 ActivityPub.flag(params)
415 # disallow objects with bogus IDs
416 def handle_incoming(%{"id" => nil}, _options), do: :error
417 def handle_incoming(%{"id" => ""}, _options), do: :error
418 # length of https:// = 8, should validate better, but good enough for now.
419 def handle_incoming(%{"id" => id}, _options) when not (is_binary(id) and length(id) > 8),
422 # TODO: validate those with a Ecto scheme
426 %{"type" => "Create", "object" => %{"type" => objtype} = object} = data,
429 when objtype in ["Article", "Note", "Video", "Page", "Question", "Answer"] do
430 actor = Containment.get_actor(data)
433 Map.put(data, "actor", actor)
436 with nil <- Activity.get_create_by_object_ap_id(object["id"]),
437 {:ok, %User{} = user} <- User.get_or_fetch_by_ap_id(data["actor"]) do
438 options = Keyword.put(options, :depth, (options[:depth] || 0) + 1)
439 object = fix_object(data["object"], options)
445 context: object["conversation"],
447 published: data["published"],
456 ActivityPub.create(params)
458 %Activity{} = activity -> {:ok, activity}
464 %{"type" => "Follow", "object" => followed, "actor" => follower, "id" => id} = data,
467 with %User{local: true} = followed <-
468 User.get_cached_by_ap_id(Containment.get_actor(%{"actor" => followed})),
469 {:ok, %User{} = follower} <-
470 User.get_or_fetch_by_ap_id(Containment.get_actor(%{"actor" => follower})),
471 {:ok, activity} <- ActivityPub.follow(follower, followed, id, false) do
472 with deny_follow_blocked <- Pleroma.Config.get([:user, :deny_follow_blocked]),
473 {_, false} <- {:user_blocked, User.blocks?(followed, follower) && deny_follow_blocked},
474 {_, false} <- {:user_locked, User.locked?(followed)},
475 {_, {:ok, follower}} <- {:follow, User.follow(follower, followed)},
477 {:follow_state_update, Utils.update_follow_state_for_all(activity, "accept")} do
478 ActivityPub.accept(%{
479 to: [follower.ap_id],
485 {:user_blocked, true} ->
486 {:ok, _} = Utils.update_follow_state_for_all(activity, "reject")
488 ActivityPub.reject(%{
489 to: [follower.ap_id],
495 {:follow, {:error, _}} ->
496 {:ok, _} = Utils.update_follow_state_for_all(activity, "reject")
498 ActivityPub.reject(%{
499 to: [follower.ap_id],
505 {:user_locked, true} ->
517 %{"type" => "Accept", "object" => follow_object, "actor" => _actor, "id" => _id} = data,
520 with actor <- Containment.get_actor(data),
521 {:ok, %User{} = followed} <- User.get_or_fetch_by_ap_id(actor),
522 {:ok, follow_activity} <- get_follow_activity(follow_object, followed),
523 {:ok, follow_activity} <- Utils.update_follow_state_for_all(follow_activity, "accept"),
524 %User{local: true} = follower <- User.get_cached_by_ap_id(follow_activity.data["actor"]),
525 {:ok, _follower} = User.follow(follower, followed) do
526 ActivityPub.accept(%{
527 to: follow_activity.data["to"],
530 object: follow_activity.data["id"],
539 %{"type" => "Reject", "object" => follow_object, "actor" => _actor, "id" => _id} = data,
542 with actor <- Containment.get_actor(data),
543 {:ok, %User{} = followed} <- User.get_or_fetch_by_ap_id(actor),
544 {:ok, follow_activity} <- get_follow_activity(follow_object, followed),
545 {:ok, follow_activity} <- Utils.update_follow_state_for_all(follow_activity, "reject"),
546 %User{local: true} = follower <- User.get_cached_by_ap_id(follow_activity.data["actor"]),
548 ActivityPub.reject(%{
549 to: follow_activity.data["to"],
552 object: follow_activity.data["id"],
555 User.unfollow(follower, followed)
564 %{"type" => "Like", "object" => object_id, "actor" => _actor, "id" => id} = data,
567 with actor <- Containment.get_actor(data),
568 {:ok, %User{} = actor} <- User.get_or_fetch_by_ap_id(actor),
569 {:ok, object} <- get_obj_helper(object_id),
570 {:ok, activity, _object} <- ActivityPub.like(actor, object, id, false) do
578 %{"type" => "Announce", "object" => object_id, "actor" => _actor, "id" => id} = data,
581 with actor <- Containment.get_actor(data),
582 {:ok, %User{} = actor} <- User.get_or_fetch_by_ap_id(actor),
583 {:ok, object} <- get_obj_helper(object_id),
584 public <- Visibility.is_public?(data),
585 {:ok, activity, _object} <- ActivityPub.announce(actor, object, id, false, public) do
593 %{"type" => "Update", "object" => %{"type" => object_type} = object, "actor" => actor_id} =
597 when object_type in ["Person", "Application", "Service", "Organization"] do
598 with %User{ap_id: ^actor_id} = actor <- User.get_cached_by_ap_id(object["id"]) do
599 {:ok, new_user_data} = ActivityPub.user_data_from_user_object(object)
601 banner = new_user_data[:info][:banner]
602 locked = new_user_data[:info][:locked] || false
603 attachment = get_in(new_user_data, [:info, :source_data, "attachment"]) || []
607 |> Enum.filter(fn %{"type" => t} -> t == "PropertyValue" end)
608 |> Enum.map(fn fields -> Map.take(fields, ["name", "value"]) end)
612 |> Map.take([:name, :bio, :avatar])
613 |> Map.put(:info, %{banner: banner, locked: locked, fields: fields})
616 |> User.upgrade_changeset(update_data, true)
617 |> User.update_and_set_cache()
619 ActivityPub.update(%{
621 to: data["to"] || [],
622 cc: data["cc"] || [],
633 # TODO: We presently assume that any actor on the same origin domain as the object being
634 # deleted has the rights to delete that object. A better way to validate whether or not
635 # the object should be deleted is to refetch the object URI, which should return either
636 # an error or a tombstone. This would allow us to verify that a deletion actually took
639 %{"type" => "Delete", "object" => object_id, "actor" => actor, "id" => _id} = data,
642 object_id = Utils.get_ap_id(object_id)
644 with actor <- Containment.get_actor(data),
645 {:ok, %User{} = actor} <- User.get_or_fetch_by_ap_id(actor),
646 {:ok, object} <- get_obj_helper(object_id),
647 :ok <- Containment.contain_origin(actor.ap_id, object.data),
648 {:ok, activity} <- ActivityPub.delete(object, false) do
652 case User.get_cached_by_ap_id(object_id) do
653 %User{ap_id: ^actor} = user ->
668 "object" => %{"type" => "Announce", "object" => object_id},
674 with actor <- Containment.get_actor(data),
675 {:ok, %User{} = actor} <- User.get_or_fetch_by_ap_id(actor),
676 {:ok, object} <- get_obj_helper(object_id),
677 {:ok, activity, _} <- ActivityPub.unannounce(actor, object, id, false) do
687 "object" => %{"type" => "Follow", "object" => followed},
693 with %User{local: true} = followed <- User.get_cached_by_ap_id(followed),
694 {:ok, %User{} = follower} <- User.get_or_fetch_by_ap_id(follower),
695 {:ok, activity} <- ActivityPub.unfollow(follower, followed, id, false) do
696 User.unfollow(follower, followed)
706 "object" => %{"type" => "Block", "object" => blocked},
712 with %User{local: true} = blocked <- User.get_cached_by_ap_id(blocked),
713 {:ok, %User{} = blocker} <- User.get_or_fetch_by_ap_id(blocker),
714 {:ok, activity} <- ActivityPub.unblock(blocker, blocked, id, false) do
715 User.unblock(blocker, blocked)
723 %{"type" => "Block", "object" => blocked, "actor" => blocker, "id" => id} = _data,
726 with %User{local: true} = blocked = User.get_cached_by_ap_id(blocked),
727 {:ok, %User{} = blocker} = User.get_or_fetch_by_ap_id(blocker),
728 {:ok, activity} <- ActivityPub.block(blocker, blocked, id, false) do
729 User.unfollow(blocker, blocked)
730 User.block(blocker, blocked)
740 "object" => %{"type" => "Like", "object" => object_id},
746 with actor <- Containment.get_actor(data),
747 {:ok, %User{} = actor} <- User.get_or_fetch_by_ap_id(actor),
748 {:ok, object} <- get_obj_helper(object_id),
749 {:ok, activity, _, _} <- ActivityPub.unlike(actor, object, id, false) do
756 def handle_incoming(_, _), do: :error
758 def get_obj_helper(id, options \\ []) do
759 if object = Object.normalize(id, true, options), do: {:ok, object}, else: nil
762 def set_reply_to_uri(%{"inReplyTo" => in_reply_to} = object) when is_binary(in_reply_to) do
763 with false <- String.starts_with?(in_reply_to, "http"),
764 {:ok, %{data: replied_to_object}} <- get_obj_helper(in_reply_to) do
765 Map.put(object, "inReplyTo", replied_to_object["external_url"] || in_reply_to)
771 def set_reply_to_uri(obj), do: obj
773 # Prepares the object of an outgoing create activity.
774 def prepare_object(object) do
781 |> prepare_attachments
784 |> strip_internal_fields
785 |> strip_internal_tags
791 # internal -> Mastodon
794 def prepare_outgoing(%{"type" => "Create", "object" => object_id} = data) do
797 |> Object.normalize()
803 |> Map.put("object", object)
804 |> Map.merge(Utils.make_json_ld_header())
810 # Mastodon Accept/Reject requires a non-normalized object containing the actor URIs,
811 # because of course it does.
812 def prepare_outgoing(%{"type" => "Accept"} = data) do
813 with follow_activity <- Activity.normalize(data["object"]) do
815 "actor" => follow_activity.actor,
816 "object" => follow_activity.data["object"],
817 "id" => follow_activity.data["id"],
823 |> Map.put("object", object)
824 |> Map.merge(Utils.make_json_ld_header())
830 def prepare_outgoing(%{"type" => "Reject"} = data) do
831 with follow_activity <- Activity.normalize(data["object"]) do
833 "actor" => follow_activity.actor,
834 "object" => follow_activity.data["object"],
835 "id" => follow_activity.data["id"],
841 |> Map.put("object", object)
842 |> Map.merge(Utils.make_json_ld_header())
848 def prepare_outgoing(%{"type" => _type} = data) do
851 |> strip_internal_fields
852 |> maybe_fix_object_url
853 |> Map.merge(Utils.make_json_ld_header())
858 def maybe_fix_object_url(data) do
859 if is_binary(data["object"]) and not String.starts_with?(data["object"], "http") do
860 case get_obj_helper(data["object"]) do
861 {:ok, relative_object} ->
862 if relative_object.data["external_url"] do
865 |> Map.put("object", relative_object.data["external_url"])
871 Logger.error("Couldn't fetch #{data["object"]} #{inspect(e)}")
879 def add_hashtags(object) do
881 (object["tag"] || [])
883 # Expand internal representation tags into AS2 tags.
884 tag when is_binary(tag) ->
886 "href" => Pleroma.Web.Endpoint.url() <> "/tags/#{tag}",
891 # Do not process tags which are already AS2 tag objects.
892 tag when is_map(tag) ->
897 |> Map.put("tag", tags)
900 def add_mention_tags(object) do
903 |> Utils.get_notified_from_object()
904 |> Enum.map(fn user ->
905 %{"type" => "Mention", "href" => user.ap_id, "name" => "@#{user.nickname}"}
908 tags = object["tag"] || []
911 |> Map.put("tag", tags ++ mentions)
914 def add_emoji_tags(%User{info: %{"emoji" => _emoji} = user_info} = object) do
915 user_info = add_emoji_tags(user_info)
918 |> Map.put(:info, user_info)
921 # TODO: we should probably send mtime instead of unix epoch time for updated
922 def add_emoji_tags(%{"emoji" => emoji} = object) do
923 tags = object["tag"] || []
927 |> Enum.map(fn {name, url} ->
929 "icon" => %{"url" => url, "type" => "Image"},
930 "name" => ":" <> name <> ":",
932 "updated" => "1970-01-01T00:00:00Z",
938 |> Map.put("tag", tags ++ out)
941 def add_emoji_tags(object) do
945 def set_conversation(object) do
946 Map.put(object, "conversation", object["context"])
949 def set_sensitive(object) do
950 tags = object["tag"] || []
951 Map.put(object, "sensitive", "nsfw" in tags)
954 def set_type(%{"type" => "Answer"} = object) do
955 Map.put(object, "type", "Note")
958 def set_type(object), do: object
960 def add_attributed_to(object) do
961 attributed_to = object["attributedTo"] || object["actor"]
964 |> Map.put("attributedTo", attributed_to)
967 def prepare_attachments(object) do
969 (object["attachment"] || [])
970 |> Enum.map(fn data ->
971 [%{"mediaType" => media_type, "href" => href} | _] = data["url"]
972 %{"url" => href, "mediaType" => media_type, "name" => data["name"], "type" => "Document"}
976 |> Map.put("attachment", attachments)
979 defp strip_internal_fields(object) do
985 "announcement_count",
988 "deleted_activity_id"
992 defp strip_internal_tags(%{"tag" => tags} = object) do
995 |> Enum.filter(fn x -> is_map(x) end)
998 |> Map.put("tag", tags)
1001 defp strip_internal_tags(object), do: object
1003 def perform(:user_upgrade, user) do
1004 # we pass a fake user so that the followers collection is stripped away
1005 old_follower_address = User.ap_followers(%User{nickname: user.nickname})
1010 where: ^old_follower_address in u.following,
1015 "array_replace(?,?,?)",
1017 ^old_follower_address,
1018 ^user.follower_address
1024 Repo.update_all(q, [])
1026 maybe_retire_websub(user.ap_id)
1031 where: ^old_follower_address in a.recipients,
1036 "array_replace(?,?,?)",
1038 ^old_follower_address,
1039 ^user.follower_address
1045 Repo.update_all(q, [])
1048 def upgrade_user_from_ap_id(ap_id) do
1049 with %User{local: false} = user <- User.get_cached_by_ap_id(ap_id),
1050 {:ok, data} <- ActivityPub.fetch_and_prepare_user_from_ap_id(ap_id),
1051 already_ap <- User.ap_enabled?(user),
1052 {:ok, user} <- user |> User.upgrade_changeset(data) |> User.update_and_set_cache() do
1053 unless already_ap do
1054 PleromaJobQueue.enqueue(:transmogrifier, __MODULE__, [:user_upgrade, user])
1059 %User{} = user -> {:ok, user}
1064 def maybe_retire_websub(ap_id) do
1065 # some sanity checks
1066 if is_binary(ap_id) && String.length(ap_id) > 8 do
1069 ws in Pleroma.Web.Websub.WebsubClientSubscription,
1070 where: fragment("? like ?", ws.topic, ^"#{ap_id}%")
1077 def maybe_fix_user_url(data) do
1078 if is_map(data["url"]) do
1079 Map.put(data, "url", data["url"]["href"])
1085 def maybe_fix_user_object(data) do
1087 |> maybe_fix_user_url