@@ -10,12 +10,12 @@ defmodule GroupherServer.Accounts.Embeds.CollectFolderMeta.Macros do
10
10
field(:has_repo, :boolean, default: false)
11
11
field(:repo_count, :integer, default: 0)
12
12
"""
13
- alias GroupherServer.Accounts.CollectFolder
13
+ import Helper.Utils , only: [ get_config: 2 ]
14
14
15
- @ supported_threads CollectFolder . supported_threads ( )
15
+ @ article_threads get_config ( :article , :article_threads )
16
16
17
17
defmacro threads_fields ( ) do
18
- @ supported_threads
18
+ @ article_threads
19
19
|> Enum . map ( fn thread ->
20
20
quote do
21
21
field ( unquote ( :"has_#{ thread } " ) , :boolean , default: false )
27
27
28
28
defmodule GroupherServer.Accounts.Embeds.CollectFolderMeta do
29
29
@ moduledoc """
30
- general article meta info for article-like content, like @supported_threads
30
+ general article meta info for articles
31
31
"""
32
32
use Ecto.Schema
33
33
import Ecto.Changeset
34
34
import GroupherServer.Accounts.Embeds.CollectFolderMeta.Macros
35
+ import Helper.Utils , only: [ get_config: 2 ]
35
36
36
- alias GroupherServer.Accounts.CollectFolder
37
+ @ article_threads get_config ( :article , :article_threads )
37
38
38
- @ supported_threads CollectFolder . supported_threads ( )
39
-
40
- @ optional_fields Enum . map ( @ supported_threads , & :"#{ & 1 } _count" ) ++
41
- Enum . map ( @ supported_threads , & :"has_#{ & 1 } " )
39
+ @ optional_fields Enum . map ( @ article_threads , & :"#{ & 1 } _count" ) ++
40
+ Enum . map ( @ article_threads , & :"has_#{ & 1 } " )
42
41
43
42
def default_meta ( ) do
44
- @ supported_threads
43
+ @ article_threads
45
44
|> Enum . reduce ( [ ] , fn thread , acc -> acc ++ [ "#{ thread } _count": 0 , "has_#{ thread } ": false ] end )
46
45
|> Enum . into ( % { } )
47
46
end
0 commit comments