alias Pleroma.{Repo, Activity, Notification}
import Ecto.Query
+ @type t :: %__MODULE__{}
+
# https://github.com/tootsuite/mastodon/blob/master/app/models/notification.rb#L19
@mastodon_notification_types %{
"Create" => "mention",
|> Enum.filter(fn user -> user && !user.local end)
end
- defp send_to_user(%{info: %{salmon: salmon}}, feed, poster) do
+ # push an activity to remote accounts
+ #
+ defp send_to_user(%{info: %{salmon: salmon}}, feed, poster),
+ do: send_to_user(salmon, feed, poster)
+
+ defp send_to_user(url, feed, poster) when is_binary(url) do
with {:ok, %{status: code}} <-
poster.(
- salmon,
+ url,
feed,
[{"Content-Type", "application/magic-envelope+xml"}]
) do
- Logger.debug(fn -> "Pushed to #{salmon}, code #{code}" end)
+ Logger.debug(fn -> "Pushed to #{url}, code #{code}" end)
else
- e -> Logger.debug(fn -> "Pushing Salmon to #{salmon} failed, #{inspect(e)}" end)
+ e -> Logger.debug(fn -> "Pushing Salmon to #{url} failed, #{inspect(e)}" end)
end
end
"Undo",
"Delete"
]
+
+ @doc """
+ Publishes an activity to remote accounts
+ """
+ @spec publish(User.t(), Pleroma.Activity.t(), Pleroma.HTTP.t()) :: none
def publish(user, activity, poster \\ &@httpoison.post/3)
def publish(%{info: %{keys: keys}} = user, %{data: %{"type" => type}} = activity, poster)