diff --git a/lib/pleroma/user/email_list.ex b/lib/pleroma/user/email_list.ex index d9e4e8658..a483d91e0 100644 --- a/lib/pleroma/user/email_list.ex +++ b/lib/pleroma/user/email_list.ex @@ -50,11 +50,15 @@ defmodule Pleroma.User.EmailList do |> build_csv() end + defp subscribe?(%User{} = user) do + user.accepts_email_list && user.is_active && user.is_approved && user.is_confirmed + end + defp build_row(%User{} = user) do [ user.email, user.nickname, - user.accepts_email_list + subscribe?(user) ] end diff --git a/test/pleroma/user/email_list_test.exs b/test/pleroma/user/email_list_test.exs index 162e21ff8..8f7c2a6ae 100644 --- a/test/pleroma/user/email_list_test.exs +++ b/test/pleroma/user/email_list_test.exs @@ -41,17 +41,21 @@ defmodule Pleroma.User.EmailListTest do end test "generate_csv/1 with :combined" do - user1 = insert(:user, accepts_email_list: true) - user2 = insert(:user, accepts_email_list: false) - user3 = insert(:user, accepts_email_list: false) - user4 = insert(:user, accepts_email_list: true) + user1 = insert(:user, accepts_email_list: true, is_active: false) + user2 = insert(:user, accepts_email_list: true) + user3 = insert(:user, accepts_email_list: true, is_approved: false) + user4 = insert(:user, accepts_email_list: true, is_confirmed: false) + user5 = insert(:user, accepts_email_list: true) + user6 = insert(:user, accepts_email_list: false) expected = """ Email Address,Nickname,Subscribe?\r - #{user1.email},#{user1.nickname},true\r - #{user2.email},#{user2.nickname},false\r + #{user1.email},#{user1.nickname},false\r + #{user2.email},#{user2.nickname},true\r #{user3.email},#{user3.nickname},false\r - #{user4.email},#{user4.nickname},true\r + #{user4.email},#{user4.nickname},false\r + #{user5.email},#{user5.nickname},true\r + #{user6.email},#{user6.nickname},false\r """ assert EmailList.generate_csv(:combined) == expected