@@ -20,7 +20,7 @@ defmodule GroupherServer.CMS.Delegate.ArticleCURD do
2020 alias Accounts.User
2121 alias CMS . { Author , Community , PinnedArticle , Embeds , Delegate , Tag }
2222
23- alias Delegate.ArticleOperation
23+ alias Delegate.ArticleCommunity
2424
2525 alias Ecto.Multi
2626
@@ -130,19 +130,19 @@ defmodule GroupherServer.CMS.Delegate.ArticleCURD do
130130 { :ok , community } <- ORM . find ( Community , cid ) do
131131 Multi . new ( )
132132 |> Multi . run ( :create_article , fn _ , _ ->
133- do_create_content ( action . target , attrs , author , community )
133+ do_create_article ( action . target , attrs , author , community )
134134 end )
135- |> Multi . run ( :set_community , fn _ , % { create_article: content } ->
136- ArticleOperation . set_community ( community , thread , content . id )
135+ |> Multi . run ( :mirror_article , fn _ , % { create_article: article } ->
136+ ArticleCommunity . mirror_article ( thread , article . id , community . id )
137137 end )
138- |> Multi . run ( :set_community_flag , fn _ , % { create_article: content } ->
139- exec_set_community_flag ( community , content , action )
138+ |> Multi . run ( :set_community_flag , fn _ , % { create_article: article } ->
139+ exec_set_community_flag ( community , article , action )
140140 end )
141- |> Multi . run ( :set_tag , fn _ , % { create_article: content } ->
142- exec_set_tag ( thread , content . id , attrs )
141+ |> Multi . run ( :set_tag , fn _ , % { create_article: article } ->
142+ exec_set_tag ( thread , article . id , attrs )
143143 end )
144- |> Multi . run ( :mention_users , fn _ , % { create_article: content } ->
145- Delivery . mention_from_content ( community . raw , thread , content , attrs , % User { id: uid } )
144+ |> Multi . run ( :mention_users , fn _ , % { create_article: article } ->
145+ Delivery . mention_from_content ( community . raw , thread , article , attrs , % User { id: uid } )
146146 { :ok , :pass }
147147 end )
148148 |> Multi . run ( :log_action , fn _ , _ ->
@@ -160,7 +160,7 @@ defmodule GroupherServer.CMS.Delegate.ArticleCURD do
160160 """
161161 def notify_admin_new_content ( % { id: id } = result ) do
162162 target = result . __struct__
163- preload = [ :origial_community , author: :user ]
163+ preload = [ :original_community , author: :user ]
164164
165165 with { :ok , content } <- ORM . find ( target , id , preload: preload ) do
166166 info = % {
@@ -186,10 +186,10 @@ defmodule GroupherServer.CMS.Delegate.ArticleCURD do
186186 ORM . update ( content , args )
187187 end )
188188 |> Multi . run ( :update_edit_status , fn _ , % { update_article: update_article } ->
189- ArticleOperation . update_edit_status ( update_article )
189+ ArticleCommunity . update_edit_status ( update_article )
190190 end )
191191 |> Multi . run ( :update_tag , fn _ , _ ->
192- # TODO: move it to ArticleOperation module
192+ # TODO: move it to ArticleCommunity module
193193 exec_update_tags ( content , args )
194194 end )
195195 |> Repo . transaction ( )
@@ -368,7 +368,7 @@ defmodule GroupherServer.CMS.Delegate.ArticleCURD do
368368 { :error , [ message: "create cms content author" , code: ecode ( :create_fails ) ] }
369369 end
370370
371- defp create_content_result ( { :error , :set_community , _result , _steps } ) do
371+ defp create_content_result ( { :error , :mirror_article , _result , _steps } ) do
372372 { :error , [ message: "set community" , code: ecode ( :create_fails ) ] }
373373 end
374374
@@ -385,21 +385,21 @@ defmodule GroupherServer.CMS.Delegate.ArticleCURD do
385385 end
386386
387387 # for create content step in Multi.new
388- defp do_create_content ( target , attrs , % Author { id: aid } , % Community { id: cid } ) do
388+ defp do_create_article ( target , attrs , % Author { id: aid } , % Community { id: cid } ) do
389389 target
390390 |> struct ( )
391391 |> target . changeset ( attrs )
392392 |> Ecto.Changeset . put_change ( :emotions , @ default_emotions )
393393 |> Ecto.Changeset . put_change ( :author_id , aid )
394- |> Ecto.Changeset . put_change ( :origial_community_id , integerfy ( cid ) )
394+ |> Ecto.Changeset . put_change ( :original_community_id , integerfy ( cid ) )
395395 |> Ecto.Changeset . put_embed ( :meta , @ default_article_meta )
396396 |> Repo . insert ( )
397397 end
398398
399399 defp exec_set_tag ( thread , id , % { tags: tags } ) do
400400 try do
401401 Enum . each ( tags , fn tag ->
402- { :ok , _ } = ArticleOperation . set_tag ( thread , % Tag { id: tag . id } , id )
402+ { :ok , _ } = ArticleCommunity . set_tag ( thread , % Tag { id: tag . id } , id )
403403 end )
404404
405405 { :ok , "psss" }
@@ -412,7 +412,7 @@ defmodule GroupherServer.CMS.Delegate.ArticleCURD do
412412
413413 # TODO: flag 逻辑似乎有问题
414414 defp exec_set_community_flag ( % Community { } = community , content , % { flag: _flag } ) do
415- ArticleOperation . set_community_flags ( community , content , % {
415+ ArticleCommunity . set_community_flags ( community , content , % {
416416 trash: false
417417 } )
418418 end
0 commit comments