Merge branch 'remove-pleroma' into 'master'
Remove pleroma mentions See merge request tcit/eventos!13
This commit is contained in:
commit
32596c3624
@ -37,20 +37,6 @@ defmodule Eventos.Service.ActivityPub do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# def stream_out(%Activity{} = activity) do
|
|
||||||
# if activity.data["type"] in ["Create", "Announce"] do
|
|
||||||
# Pleroma.Web.Streamer.stream("user", activity)
|
|
||||||
#
|
|
||||||
# if Enum.member?(activity.data["to"], "https://www.w3.org/ns/activitystreams#Public") do
|
|
||||||
# Pleroma.Web.Streamer.stream("public", activity)
|
|
||||||
#
|
|
||||||
# if activity.local do
|
|
||||||
# Pleroma.Web.Streamer.stream("public:local", activity)
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
|
|
||||||
def fetch_event_from_url(url) do
|
def fetch_event_from_url(url) do
|
||||||
if object = Events.get_event_by_url!(url) do
|
if object = Events.get_event_by_url!(url) do
|
||||||
{:ok, object}
|
{:ok, object}
|
||||||
|
@ -20,7 +20,6 @@ defmodule Eventos.Service.ActivityPub.Transmogrifier do
|
|||||||
|> fix_attachments
|
|> fix_attachments
|
||||||
|> fix_context
|
|> fix_context
|
||||||
#|> fix_in_reply_to
|
#|> fix_in_reply_to
|
||||||
|> fix_emoji
|
|
||||||
|> fix_tag
|
|> fix_tag
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -62,29 +61,6 @@ defmodule Eventos.Service.ActivityPub.Transmogrifier do
|
|||||||
|> Map.put("attachment", attachments)
|
|> Map.put("attachment", attachments)
|
||||||
end
|
end
|
||||||
|
|
||||||
def fix_emoji(object) do
|
|
||||||
tags = object["tag"] || []
|
|
||||||
emoji = tags |> Enum.filter(fn data -> data["type"] == "Emoji" and data["icon"] end)
|
|
||||||
|
|
||||||
emoji =
|
|
||||||
emoji
|
|
||||||
|> Enum.reduce(%{}, fn data, mapping ->
|
|
||||||
name = data["name"]
|
|
||||||
|
|
||||||
if String.starts_with?(name, ":") do
|
|
||||||
name = name |> String.slice(1..-2)
|
|
||||||
end
|
|
||||||
|
|
||||||
mapping |> Map.put(name, data["icon"]["url"])
|
|
||||||
end)
|
|
||||||
|
|
||||||
# we merge mastodon and pleroma emoji into a single mapping, to allow for both wire formats
|
|
||||||
emoji = Map.merge(object["emoji"] || %{}, emoji)
|
|
||||||
|
|
||||||
object
|
|
||||||
|> Map.put("emoji", emoji)
|
|
||||||
end
|
|
||||||
|
|
||||||
def fix_tag(object) do
|
def fix_tag(object) do
|
||||||
tags =
|
tags =
|
||||||
(object["tag"] || [])
|
(object["tag"] || [])
|
||||||
@ -308,21 +284,6 @@ defmodule Eventos.Service.ActivityPub.Transmogrifier do
|
|||||||
# end
|
# end
|
||||||
# end
|
# end
|
||||||
#
|
#
|
||||||
# def add_hashtags(object) do
|
|
||||||
# tags =
|
|
||||||
# (object["tag"] || [])
|
|
||||||
# |> Enum.map(fn tag ->
|
|
||||||
# %{
|
|
||||||
# "href" => Pleroma.Web.Endpoint.url() <> "/tags/#{tag}",
|
|
||||||
# "name" => "##{tag}",
|
|
||||||
# "type" => "Hashtag"
|
|
||||||
# }
|
|
||||||
# end)
|
|
||||||
#
|
|
||||||
# object
|
|
||||||
# |> Map.put("tag", tags)
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# def add_mention_tags(object) do
|
# def add_mention_tags(object) do
|
||||||
# recipients = object["to"] ++ (object["cc"] || [])
|
# recipients = object["to"] ++ (object["cc"] || [])
|
||||||
#
|
#
|
||||||
@ -468,16 +429,4 @@ defmodule Eventos.Service.ActivityPub.Transmogrifier do
|
|||||||
# end
|
# end
|
||||||
# end
|
# end
|
||||||
#
|
#
|
||||||
# def maybe_retire_websub(ap_id) do
|
|
||||||
# # some sanity checks
|
|
||||||
# if is_binary(ap_id) && String.length(ap_id) > 8 do
|
|
||||||
# q =
|
|
||||||
# from(
|
|
||||||
# ws in Pleroma.Web.Websub.WebsubClientSubscription,
|
|
||||||
# where: fragment("? like ?", ws.topic, ^"#{ap_id}%")
|
|
||||||
# )
|
|
||||||
#
|
|
||||||
# Repo.delete_all(q)
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
end
|
end
|
||||||
|
@ -46,49 +46,6 @@ defmodule Eventos.Service.Streamer do
|
|||||||
{:noreply, topics}
|
{:noreply, topics}
|
||||||
end
|
end
|
||||||
|
|
||||||
# def handle_cast(%{action: :stream, topic: "user", item: %Notification{} = item}, topics) do
|
|
||||||
# topic = "user:#{item.user_id}"
|
|
||||||
#
|
|
||||||
# Enum.each(topics[topic] || [], fn socket ->
|
|
||||||
# json =
|
|
||||||
# %{
|
|
||||||
# event: "notification",
|
|
||||||
# payload:
|
|
||||||
# Pleroma.Web.MastodonAPI.MastodonAPIController.render_notification(
|
|
||||||
# socket.assigns["user"],
|
|
||||||
# item
|
|
||||||
# )
|
|
||||||
# |> Jason.encode!()
|
|
||||||
# }
|
|
||||||
# |> Jason.encode!()
|
|
||||||
#
|
|
||||||
# send(socket.transport_pid, {:text, json})
|
|
||||||
# end)
|
|
||||||
#
|
|
||||||
# {:noreply, topics}
|
|
||||||
# end
|
|
||||||
|
|
||||||
def handle_cast(%{action: :stream, topic: "user", item: item}, topics) do
|
|
||||||
Logger.debug("Trying to push to users")
|
|
||||||
|
|
||||||
recipient_topics =
|
|
||||||
User.get_recipients_from_activity(item)
|
|
||||||
|> Enum.map(fn %{id: id} -> "user:#{id}" end)
|
|
||||||
|
|
||||||
Enum.each(recipient_topics, fn topic ->
|
|
||||||
push_to_socket(topics, topic, item)
|
|
||||||
end)
|
|
||||||
|
|
||||||
{:noreply, topics}
|
|
||||||
end
|
|
||||||
|
|
||||||
def handle_cast(%{action: :stream, topic: topic, item: item}, topics) do
|
|
||||||
Logger.debug("Trying to push to #{topic}")
|
|
||||||
Logger.debug("Pushing item to #{topic}")
|
|
||||||
push_to_socket(topics, topic, item)
|
|
||||||
{:noreply, topics}
|
|
||||||
end
|
|
||||||
|
|
||||||
def handle_cast(%{action: :add, topic: topic, socket: socket}, sockets) do
|
def handle_cast(%{action: :add, topic: topic, socket: socket}, sockets) do
|
||||||
topic = internal_topic(topic, socket)
|
topic = internal_topic(topic, socket)
|
||||||
sockets_for_topic = sockets[topic] || []
|
sockets_for_topic = sockets[topic] || []
|
||||||
@ -112,31 +69,6 @@ defmodule Eventos.Service.Streamer do
|
|||||||
{:noreply, state}
|
{:noreply, state}
|
||||||
end
|
end
|
||||||
|
|
||||||
def push_to_socket(topics, topic, item) do
|
|
||||||
Enum.each(topics[topic] || [], fn socket ->
|
|
||||||
# Get the current user so we have up-to-date blocks etc.
|
|
||||||
user = User.get_cached_by_ap_id(socket.assigns[:user].ap_id)
|
|
||||||
blocks = user.info["blocks"] || []
|
|
||||||
|
|
||||||
unless item.actor in blocks do
|
|
||||||
json =
|
|
||||||
%{
|
|
||||||
event: "update",
|
|
||||||
payload:
|
|
||||||
Pleroma.Web.MastodonAPI.StatusView.render(
|
|
||||||
"status.json",
|
|
||||||
activity: item,
|
|
||||||
for: user
|
|
||||||
)
|
|
||||||
|> Jason.encode!()
|
|
||||||
}
|
|
||||||
|> Jason.encode!()
|
|
||||||
|
|
||||||
send(socket.transport_pid, {:text, json})
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
|
|
||||||
defp internal_topic("user", socket) do
|
defp internal_topic("user", socket) do
|
||||||
"user:#{socket.assigns[:user].id}"
|
"user:#{socket.assigns[:user].id}"
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user