@@ -6,7 +6,8 @@ defmodule GroupherServer.CMS.Delegate.ArticleCURD do
66
77 import GroupherServer.CMS.Helper.Matcher
88
9- import Helper.Utils , only: [ done: 1 , pick_by: 2 , module_to_atom: 1 , get_config: 2 , ensure: 2 ]
9+ import Helper.Utils ,
10+ only: [ done: 1 , pick_by: 2 , module_to_atom: 1 , get_config: 2 , ensure: 2 , module_to_upcase: 1 ]
1011
1112 import GroupherServer.CMS.Delegate.Helper , only: [ mark_viewer_emotion_states: 2 ]
1213 import Helper.ErrorCode
@@ -384,6 +385,7 @@ defmodule GroupherServer.CMS.Delegate.ArticleCURD do
384385 defp do_create_article ( model , attrs , % Author { id: author_id } , % Community { id: community_id } ) do
385386 # special article like Repo do not have :body, assign it with default-empty rich text
386387 body = Map . get ( attrs , :body , Converter.Article . default_rich_text ( ) )
388+ meta = @ default_article_meta |> Map . merge ( % { thread: module_to_upcase ( model ) } )
387389 attrs = attrs |> Map . merge ( % { body: body } )
388390
389391 with { :ok , attrs } <- add_rich_text_attrs ( attrs ) do
@@ -392,7 +394,7 @@ defmodule GroupherServer.CMS.Delegate.ArticleCURD do
392394 |> Ecto.Changeset . put_change ( :emotions , @ default_emotions )
393395 |> Ecto.Changeset . put_change ( :author_id , author_id )
394396 |> Ecto.Changeset . put_change ( :original_community_id , community_id )
395- |> Ecto.Changeset . put_embed ( :meta , @ default_article_meta )
397+ |> Ecto.Changeset . put_embed ( :meta , meta )
396398 |> Repo . insert ( )
397399 end
398400 end
0 commit comments