removing not needed invite update

This commit is contained in:
Alex S 2019-04-08 20:08:16 +07:00
parent d0696fdfd6
commit fee50636d0
2 changed files with 3 additions and 4 deletions

View file

@ -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 not_overdue_date?(invite) and invite.uses < invite.max_use and not invite.used
end end
defp not_overdue_date?(%{expires_at: expires_at} = invite) do defp not_overdue_date?(%{expires_at: expires_at}) do
Date.compare(Date.utc_today(), expires_at) in [:lt, :eq] || Date.compare(Date.utc_today(), expires_at) in [:lt, :eq]
(update_invite!(invite, %{used: true}) && false)
end end
@spec update_usage!(UserInviteToken.t()) :: nil | UserInviteToken.t() | no_return() @spec update_usage!(UserInviteToken.t()) :: nil | UserInviteToken.t() | no_return()

View file

@ -492,7 +492,7 @@ test "returns an error on overdue date", %{data: data} do
refute User.get_by_nickname("vinny") refute User.get_by_nickname("vinny")
invite = Repo.get_by(UserInviteToken, token: invite.token) invite = Repo.get_by(UserInviteToken, token: invite.token)
assert invite.used == true refute invite.used
end end
end end