Set updated_at even if the object stayed the same
authorrinpatch <rinpatch@sdf.org>
Wed, 18 Sep 2019 16:07:25 +0000 (19:07 +0300)
committerAriadne Conill <ariadne@dereferenced.org>
Sun, 6 Oct 2019 14:53:29 +0000 (14:53 +0000)
lib/pleroma/object/fetcher.ex

index da1ebd8b3d3563f6dc1066cd6e5c1d630725be24..786e31cce62aa417c24ac8874b6867d45a25ef27 100644 (file)
@@ -14,11 +14,20 @@ defmodule Pleroma.Object.Fetcher do
 
   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
     Logger.debug("Reinjecting object #{data["id"]}")
 
     with data <- Transmogrifier.fix_object(data),
          changeset <- Object.change(struct, %{data: data}),
+         changeset <- touch_changeset(changeset),
          {:ok, object} <- Repo.insert_or_update(changeset) do
       {:ok, object}
     else