EmailList: add Subscribed? column

This commit is contained in:
Alex Gleason 2021-06-15 12:16:14 -05:00
parent 385d432ce7
commit 73ed23e2fd
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
2 changed files with 14 additions and 10 deletions

View File

@ -11,7 +11,7 @@ defmodule Pleroma.User.EmailList do
alias Pleroma.Repo alias Pleroma.Repo
alias Pleroma.User alias Pleroma.User
@header_row ["Email Address", "Nickname"] @header_row ["Email Address", "Nickname", "Subscribe?"]
defp query(:subscribers) do defp query(:subscribers) do
User.Query.build(%{ User.Query.build(%{
@ -43,8 +43,12 @@ defmodule Pleroma.User.EmailList do
|> build_csv() |> build_csv()
end end
defp build_row(%User{email: email, nickname: nickname}) do defp build_row(%User{} = user) do
[email, nickname] [
user.email,
user.nickname,
user.accepts_email_list
]
end end
defp build_csv(lines) do defp build_csv(lines) do

View File

@ -16,10 +16,10 @@ defmodule Pleroma.User.EmailListTest do
insert(:user, accepts_email_list: false) insert(:user, accepts_email_list: false)
expected = """ expected = """
Email Address,Nickname\r Email Address,Nickname,Subscribe?\r
#{user1.email},#{user1.nickname}\r #{user1.email},#{user1.nickname},true\r
#{user2.email},#{user2.nickname}\r #{user2.email},#{user2.nickname},true\r
#{user3.email},#{user3.nickname}\r #{user3.email},#{user3.nickname},true\r
""" """
assert EmailList.generate_csv(:subscribers) == expected assert EmailList.generate_csv(:subscribers) == expected
@ -32,9 +32,9 @@ defmodule Pleroma.User.EmailListTest do
insert(:user, accepts_email_list: true) insert(:user, accepts_email_list: true)
expected = """ expected = """
Email Address,Nickname\r Email Address,Nickname,Subscribe?\r
#{user1.email},#{user1.nickname}\r #{user1.email},#{user1.nickname},false\r
#{user2.email},#{user2.nickname}\r #{user2.email},#{user2.nickname},false\r
""" """
assert EmailList.generate_csv(:unsubscribers) == expected assert EmailList.generate_csv(:unsubscribers) == expected