local = Map.get(params, :local, true)
activity_id = Map.get(params, :activity_id, nil)
- with data <-
- %{"to" => to, "type" => type, "actor" => actor.ap_id, "object" => object}
- |> Maps.put_if_present("id", activity_id),
- {:ok, activity} <- insert(data, local),
+ data =
+ %{"to" => to, "type" => type, "actor" => actor.ap_id, "object" => object}
- |> Utils.maybe_put("id", activity_id)
++ |> Maps.put_if_present("id", activity_id)
+
+ with {:ok, activity} <- insert(data, local),
_ <- notify_and_stream(activity),
:ok <- maybe_federate(activity) do
{:ok, activity}
local = !(params[:local] == false)
activity_id = params[:activity_id]
- with data <- %{
- "to" => to,
- "cc" => cc,
- "type" => "Update",
- "actor" => actor,
- "object" => object
- },
- data <- Maps.put_if_present(data, "id", activity_id),
- {:ok, activity} <- insert(data, local),
+ data =
+ %{
+ "to" => to,
+ "cc" => cc,
+ "type" => "Update",
+ "actor" => actor,
+ "object" => object
+ }
- |> Utils.maybe_put("id", activity_id)
++ |> Maps.put_if_present("id", activity_id)
+
+ with {:ok, activity} <- insert(data, local),
_ <- notify_and_stream(activity),
:ok <- maybe_federate(activity) do
{:ok, activity}
{format, tag} = parse_tag(raw_tag)
activities =
- %{"type" => ["Create"], "tag" => tag}
- |> Pleroma.Maps.put_if_present("max_id", params["max_id"])
+ %{type: ["Create"], tag: tag}
- |> put_if_exist(:max_id, params["max_id"])
++ |> Pleroma.Maps.put_if_present(:max_id, params["max_id"])
|> ActivityPub.fetch_public_activities()
conn
with {_, %User{} = user} <- {:fetch_user, User.get_cached_by_nickname(nickname)} do
activities =
%{
- "type" => ["Create"],
- "actor_id" => user.ap_id
+ type: ["Create"],
+ actor_id: user.ap_id
}
- |> put_if_exist(:max_id, params["max_id"])
- |> Pleroma.Maps.put_if_present("max_id", params["max_id"])
++ |> Pleroma.Maps.put_if_present(:max_id, params["max_id"])
|> ActivityPub.fetch_public_or_unlisted_activities()
conn
def home(%{assigns: %{user: user}} = conn, params) do
params =
params
- |> Map.new(fn {key, value} -> {to_string(key), value} end)
- |> Map.put("type", ["Create", "Announce"])
- |> Map.put("blocking_user", user)
- |> Map.put("muting_user", user)
- |> Map.put("reply_filtering_user", user)
- |> Map.put("user", user)
+ |> Map.put(:type, ["Create", "Announce"])
+ |> Map.put(:blocking_user, user)
+ |> Map.put(:muting_user, user)
+ |> Map.put(:reply_filtering_user, user)
+ |> Map.put(:user, user)
- recipients = [user.ap_id | User.following(user)]
-
activities =
- recipients
+ [user.ap_id | User.following(user)]
|> ActivityPub.fetch_activities(params)
|> Enum.reverse()