From 73ed23e2fd6997450ba82e2e0b3301b2960751fa Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Tue, 15 Jun 2021 12:16:14 -0500 Subject: [PATCH] EmailList: add Subscribed? column --- lib/pleroma/user/email_list.ex | 10 +++++++--- test/pleroma/user/email_list_test.exs | 14 +++++++------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/lib/pleroma/user/email_list.ex b/lib/pleroma/user/email_list.ex index 3b5719805..b466fd92a 100644 --- a/lib/pleroma/user/email_list.ex +++ b/lib/pleroma/user/email_list.ex @@ -11,7 +11,7 @@ defmodule Pleroma.User.EmailList do alias Pleroma.Repo alias Pleroma.User - @header_row ["Email Address", "Nickname"] + @header_row ["Email Address", "Nickname", "Subscribe?"] defp query(:subscribers) do User.Query.build(%{ @@ -43,8 +43,12 @@ defmodule Pleroma.User.EmailList do |> build_csv() end - defp build_row(%User{email: email, nickname: nickname}) do - [email, nickname] + defp build_row(%User{} = user) do + [ + user.email, + user.nickname, + user.accepts_email_list + ] end defp build_csv(lines) do diff --git a/test/pleroma/user/email_list_test.exs b/test/pleroma/user/email_list_test.exs index ceb9aaa2e..8dbe877c5 100644 --- a/test/pleroma/user/email_list_test.exs +++ b/test/pleroma/user/email_list_test.exs @@ -16,10 +16,10 @@ defmodule Pleroma.User.EmailListTest do insert(:user, accepts_email_list: false) expected = """ - Email Address,Nickname\r - #{user1.email},#{user1.nickname}\r - #{user2.email},#{user2.nickname}\r - #{user3.email},#{user3.nickname}\r + Email Address,Nickname,Subscribe?\r + #{user1.email},#{user1.nickname},true\r + #{user2.email},#{user2.nickname},true\r + #{user3.email},#{user3.nickname},true\r """ assert EmailList.generate_csv(:subscribers) == expected @@ -32,9 +32,9 @@ defmodule Pleroma.User.EmailListTest do insert(:user, accepts_email_list: true) expected = """ - Email Address,Nickname\r - #{user1.email},#{user1.nickname}\r - #{user2.email},#{user2.nickname}\r + Email Address,Nickname,Subscribe?\r + #{user1.email},#{user1.nickname},false\r + #{user2.email},#{user2.nickname},false\r """ assert EmailList.generate_csv(:unsubscribers) == expected