From fee50636d07c54328ececfe8805c658e3bb80cc6 Mon Sep 17 00:00:00 2001 From: Alex S Date: Mon, 8 Apr 2019 20:08:16 +0700 Subject: [PATCH] removing not needed invite update --- lib/pleroma/user_invite_token.ex | 5 ++--- test/web/twitter_api/twitter_api_test.exs | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/pleroma/user_invite_token.ex b/lib/pleroma/user_invite_token.ex index 6247831d5..86f0a5486 100644 --- a/lib/pleroma/user_invite_token.ex +++ b/lib/pleroma/user_invite_token.ex @@ -96,9 +96,8 @@ def valid_invite?(%{invite_type: "reusable_date_limited"} = invite) do not_overdue_date?(invite) and invite.uses < invite.max_use and not invite.used end - defp not_overdue_date?(%{expires_at: expires_at} = invite) do - Date.compare(Date.utc_today(), expires_at) in [:lt, :eq] || - (update_invite!(invite, %{used: true}) && false) + defp not_overdue_date?(%{expires_at: expires_at}) do + Date.compare(Date.utc_today(), expires_at) in [:lt, :eq] end @spec update_usage!(UserInviteToken.t()) :: nil | UserInviteToken.t() | no_return() diff --git a/test/web/twitter_api/twitter_api_test.exs b/test/web/twitter_api/twitter_api_test.exs index 798a009fe..a4540e651 100644 --- a/test/web/twitter_api/twitter_api_test.exs +++ b/test/web/twitter_api/twitter_api_test.exs @@ -492,7 +492,7 @@ test "returns an error on overdue date", %{data: data} do refute User.get_by_nickname("vinny") invite = Repo.get_by(UserInviteToken, token: invite.token) - assert invite.used == true + refute invite.used end end