Fix event updates
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
parent
58e0ca0d68
commit
9ff0eb5c4b
4 changed files with 20 additions and 8 deletions
|
@ -45,7 +45,13 @@ defmodule Pleroma.Constants do
|
|||
"summary",
|
||||
"sensitive",
|
||||
"attachment",
|
||||
"generator"
|
||||
"generator",
|
||||
"startTime",
|
||||
"endTime",
|
||||
"location",
|
||||
"location_id",
|
||||
"location_provider",
|
||||
"name"
|
||||
]
|
||||
)
|
||||
|
||||
|
|
|
@ -124,6 +124,11 @@ def make_update_object_data(original_data, new_data, date) do
|
|||
original_data
|
||||
|> update_content_fields(new_data)
|
||||
|
||||
IO.inspect(updated_data)
|
||||
IO.inspect(updated)
|
||||
IO.inspect(original_data)
|
||||
IO.inspect(new_data)
|
||||
|
||||
if not updated do
|
||||
updated_data
|
||||
else
|
||||
|
|
|
@ -744,9 +744,9 @@ def event(user, data, location \\ nil) do
|
|||
end
|
||||
end
|
||||
|
||||
def update_event(user, orig_activity, changes) do
|
||||
def update_event(user, orig_activity, changes, location \\ nil) do
|
||||
with orig_object <- Object.normalize(orig_activity),
|
||||
{:ok, new_object} <- make_update_event_data(user, orig_object, changes),
|
||||
{:ok, new_object} <- make_update_event_data(user, orig_object, changes, location),
|
||||
{:ok, update_data, _} <- Builder.update(user, new_object),
|
||||
{:ok, update, _} <- Pipeline.common_pipeline(update_data, local: true) do
|
||||
{:ok, update}
|
||||
|
@ -755,7 +755,7 @@ def update_event(user, orig_activity, changes) do
|
|||
end
|
||||
end
|
||||
|
||||
defp make_update_event_data(user, orig_object, changes) do
|
||||
defp make_update_event_data(user, orig_object, changes, location) do
|
||||
kept_params = %{
|
||||
visibility: Visibility.get_visibility(orig_object),
|
||||
in_reply_to_id:
|
||||
|
@ -769,7 +769,7 @@ defp make_update_event_data(user, orig_object, changes) do
|
|||
|
||||
params = Map.merge(changes, kept_params)
|
||||
|
||||
with {:ok, draft} <- ActivityDraft.event(user, params) do
|
||||
with {:ok, draft} <- ActivityDraft.event(user, params, location) do
|
||||
change =
|
||||
Object.Updater.make_update_object_data(orig_object.data, draft.object, Utils.make_date())
|
||||
|
||||
|
|
|
@ -99,7 +99,7 @@ def create(%{assigns: %{user: user}, body_params: params} = conn, _) do
|
|||
end
|
||||
end
|
||||
|
||||
@doc "PUT /api/v1/statuses/:id"
|
||||
@doc "PUT /api/v1/pleroma/events/:id"
|
||||
def update(%{assigns: %{user: user}, body_params: body_params} = conn, %{id: id} = params) do
|
||||
with {_, %Activity{}} = {_, activity} <- {:activity, Activity.get_by_id_with_object(id)},
|
||||
{_, true} <- {:visible, Visibility.visible_for_user?(activity, user)},
|
||||
|
@ -107,8 +107,9 @@ def update(%{assigns: %{user: user}, body_params: body_params} = conn, %{id: id}
|
|||
actor <- Activity.user_actor(activity),
|
||||
{_, true} <- {:own_status, actor.id == user.id},
|
||||
changes <- body_params |> Map.put(:application, conn.assigns.application),
|
||||
location <- get_location(body_params),
|
||||
{_, {:ok, _update_activity}} <-
|
||||
{:pipeline, CommonAPI.update_event(user, activity, changes)},
|
||||
{:pipeline, CommonAPI.update_event(user, activity, changes, location)},
|
||||
{_, %Activity{}} = {_, activity} <- {:refetched, Activity.get_by_id_with_object(id)} do
|
||||
conn
|
||||
|> put_view(StatusView)
|
||||
|
@ -120,7 +121,7 @@ def update(%{assigns: %{user: user}, body_params: body_params} = conn, %{id: id}
|
|||
)
|
||||
else
|
||||
{:own_status, _} -> {:error, :forbidden}
|
||||
{:pipeline, e} -> {:error, :internal_server_error}
|
||||
{:pipeline, _} -> {:error, :internal_server_error}
|
||||
_ -> {:error, :not_found}
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue