From 597f56b4c4db3c63ff66fc93717d3b20655e1543 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcin=20miko=C5=82ajczak?= Date: Sat, 16 Jul 2022 16:09:47 +0200 Subject: [PATCH] Use :utc_datetime MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: marcin mikołajczak --- lib/pleroma/user.ex | 4 ++-- lib/pleroma/user_relationship.ex | 2 +- .../20220616163503_add_expires_at_to_user_relationships.exs | 2 +- test/pleroma/web/mastodon_api/views/account_view_test.exs | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index 88837b91a..44754879a 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -1463,8 +1463,8 @@ defmodule Pleroma.User do expires_at = if expires_in > 0 do - NaiveDateTime.utc_now() - |> NaiveDateTime.add(expires_in) + DateTime.utc_now() + |> DateTime.add(expires_in) else nil end diff --git a/lib/pleroma/user_relationship.ex b/lib/pleroma/user_relationship.ex index f35f3ac63..5b3e593d3 100644 --- a/lib/pleroma/user_relationship.ex +++ b/lib/pleroma/user_relationship.ex @@ -18,7 +18,7 @@ defmodule Pleroma.UserRelationship do belongs_to(:source, User, type: FlakeId.Ecto.CompatType) belongs_to(:target, User, type: FlakeId.Ecto.CompatType) field(:relationship_type, Pleroma.UserRelationship.Type) - field(:expires_at, :naive_datetime) + field(:expires_at, :utc_datetime) timestamps(updated_at: false) end diff --git a/priv/repo/migrations/20220616163503_add_expires_at_to_user_relationships.exs b/priv/repo/migrations/20220616163503_add_expires_at_to_user_relationships.exs index c0594d647..9e117e376 100644 --- a/priv/repo/migrations/20220616163503_add_expires_at_to_user_relationships.exs +++ b/priv/repo/migrations/20220616163503_add_expires_at_to_user_relationships.exs @@ -7,7 +7,7 @@ defmodule Pleroma.Repo.Migrations.AddExpiresAtToUserRelationships do def change do alter table(:user_relationships) do - add_if_not_exists(:expires_at, :naive_datetime) + add_if_not_exists(:expires_at, :utc_datetime) end end end diff --git a/test/pleroma/web/mastodon_api/views/account_view_test.exs b/test/pleroma/web/mastodon_api/views/account_view_test.exs index cc45ce4e9..8fa946d43 100644 --- a/test/pleroma/web/mastodon_api/views/account_view_test.exs +++ b/test/pleroma/web/mastodon_api/views/account_view_test.exs @@ -646,9 +646,9 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do mute_expires_at: mute_expires_at } = AccountView.render("show.json", %{user: other_user, for: user, mutes: true}) - assert NaiveDateTime.diff( + assert DateTime.diff( mute_expires_at, - NaiveDateTime.utc_now() |> NaiveDateTime.add(24 * 60 * 60) + DateTime.utc_now() |> DateTime.add(24 * 60 * 60) ) in -3..3 end end