|> handle_incoming(options)
end
+ def handle_incoming(
+ %{"type" => "Create", "object" => %{"type" => "ChatMessage"}} = data,
+ _options
+ ) do
+ with {:ok, %User{}} <- ObjectValidator.fetch_actor(data),
+ {:ok, activity, _} <- Pipeline.common_pipeline(data, local: false) do
+ {:ok, activity}
+ end
+ end
+
def handle_incoming(%{"type" => "Like"} = data, _options) do
- with {_, {:ok, cast_data_sym}} <-
- {:casting_data,
- data |> LikeValidator.cast_data() |> Ecto.Changeset.apply_action(:insert)},
- cast_data = ObjectValidator.stringify_keys(Map.from_struct(cast_data_sym)),
- :ok <- ObjectValidator.fetch_actor_and_object(cast_data),
- {_, {:ok, cast_data}} <- {:ensure_context_presence, ensure_context_presence(cast_data)},
- {_, {:ok, cast_data}} <-
- {:ensure_recipients_presence, ensure_recipients_presence(cast_data)},
- {_, {:ok, activity, _meta}} <-
- {:common_pipeline, Pipeline.common_pipeline(cast_data, local: false)} do
+ with :ok <- ObjectValidator.fetch_actor_and_object(data),
+ {:ok, activity, _meta} <-
+ Pipeline.common_pipeline(data, local: false) do
{:ok, activity}
else
e -> {:error, e}