Set updated_at even if the object stayed the same

This commit is contained in:
rinpatch 2019-09-18 19:07:25 +03:00 committed by Ariadne Conill
parent 8be9a9b5bb
commit b9cdead076
1 changed files with 9 additions and 0 deletions

View File

@ -14,11 +14,20 @@ defmodule Pleroma.Object.Fetcher do
require Logger require Logger
defp touch_changeset(changeset) do
updated_at =
NaiveDateTime.utc_now()
|> NaiveDateTime.truncate(:second)
Ecto.Changeset.put_change(changeset, :updated_at, updated_at)
end
defp reinject_object(struct, data) do defp reinject_object(struct, data) do
Logger.debug("Reinjecting object #{data["id"]}") Logger.debug("Reinjecting object #{data["id"]}")
with data <- Transmogrifier.fix_object(data), with data <- Transmogrifier.fix_object(data),
changeset <- Object.change(struct, %{data: data}), changeset <- Object.change(struct, %{data: data}),
changeset <- touch_changeset(changeset),
{:ok, object} <- Repo.insert_or_update(changeset) do {:ok, object} <- Repo.insert_or_update(changeset) do
{:ok, object} {:ok, object}
else else