@@ -41,14 +41,6 @@ defmodule MastaniServer.CMS.Delegate.ArticleOperation do
4141 end
4242 end
4343
44- def undo_pin_content ( % Post { id: post_id } , % Community { id: community_id } , topic ) do
45- with { :ok , % { id: topic_id } } <- ORM . find_by ( Topic , % { raw: topic } ) ,
46- { :ok , pined } <- ORM . find_by ( PinedPost , ~m( post_id community_id topic_id) a ) ,
47- { :ok , deleted } <- ORM . delete ( pined ) do
48- Post |> ORM . find ( deleted . post_id )
49- end
50- end
51-
5244 def pin_content ( % Job { id: job_id } , % Community { id: community_id } ) do
5345 attrs = ~m( job_id community_id) a
5446
@@ -57,13 +49,6 @@ defmodule MastaniServer.CMS.Delegate.ArticleOperation do
5749 end
5850 end
5951
60- def undo_pin_content ( % Job { id: job_id } , % Community { id: community_id } ) do
61- with { :ok , pined } <- ORM . find_by ( PinedJob , ~m( job_id community_id) a ) ,
62- { :ok , deleted } <- ORM . delete ( pined ) do
63- Job |> ORM . find ( deleted . job_id )
64- end
65- end
66-
6752 def pin_content ( % Video { id: video_id } , % Community { id: community_id } ) do
6853 attrs = ~m( video_id community_id) a
6954
@@ -72,13 +57,6 @@ defmodule MastaniServer.CMS.Delegate.ArticleOperation do
7257 end
7358 end
7459
75- def undo_pin_content ( % Video { id: video_id } , % Community { id: community_id } ) do
76- with { :ok , pined } <- ORM . find_by ( PinedVideo , ~m( video_id community_id) a ) ,
77- { :ok , deleted } <- ORM . delete ( pined ) do
78- Video |> ORM . find ( deleted . video_id )
79- end
80- end
81-
8260 def pin_content ( % CMSRepo { id: repo_id } , % Community { id: community_id } ) do
8361 attrs = ~m( repo_id community_id) a
8462
@@ -87,6 +65,28 @@ defmodule MastaniServer.CMS.Delegate.ArticleOperation do
8765 end
8866 end
8967
68+ def undo_pin_content ( % Post { id: post_id } , % Community { id: community_id } , topic ) do
69+ with { :ok , % { id: topic_id } } <- ORM . find_by ( Topic , % { raw: topic } ) ,
70+ { :ok , pined } <- ORM . find_by ( PinedPost , ~m( post_id community_id topic_id) a ) ,
71+ { :ok , deleted } <- ORM . delete ( pined ) do
72+ Post |> ORM . find ( deleted . post_id )
73+ end
74+ end
75+
76+ def undo_pin_content ( % Job { id: job_id } , % Community { id: community_id } ) do
77+ with { :ok , pined } <- ORM . find_by ( PinedJob , ~m( job_id community_id) a ) ,
78+ { :ok , deleted } <- ORM . delete ( pined ) do
79+ Job |> ORM . find ( deleted . job_id )
80+ end
81+ end
82+
83+ def undo_pin_content ( % Video { id: video_id } , % Community { id: community_id } ) do
84+ with { :ok , pined } <- ORM . find_by ( PinedVideo , ~m( video_id community_id) a ) ,
85+ { :ok , deleted } <- ORM . delete ( pined ) do
86+ Video |> ORM . find ( deleted . video_id )
87+ end
88+ end
89+
9090 def undo_pin_content ( % CMSRepo { id: repo_id } , % Community { id: community_id } ) do
9191 with { :ok , pined } <- ORM . find_by ( PinedRepo , ~m( repo_id community_id) a ) ,
9292 { :ok , deleted } <- ORM . delete ( pined ) do
@@ -222,16 +222,16 @@ defmodule MastaniServer.CMS.Delegate.ArticleOperation do
222222
223223 # make sure the reuest tag is in the current community thread
224224 # example: you can't set a other thread tag to this thread's article
225- defp tag_in_community_thread? ( % Community { id: communityId } , thread , tag ) do
226- with { :ok , community } <- ORM . find ( Community , communityId ) do
227- matched_tags =
228- Tag
229- |> where ( [ t ] , t . community_id == ^ community . id )
230- # |> where([t], t.thread == ^(to_string(thread) |> String.upcase()) )
231- |> where ( [ t ] , t . thread == ^ to_string ( thread ) )
232- |> Repo . all ( )
233-
234- tag in matched_tags
235- end
236- end
225+
226+ # defp tag_in_community_thread?(%Community{id: communityId}, thread, tag ) do
227+ # with {:ok, community} <- ORM.find(Community, communityId) do
228+ # matched_tags =
229+ # Tag
230+ # |> where([t], t.community_id == ^community.id )
231+ # |> where([t], t.thread == ^to_string(thread))
232+ # |> Repo.all()
233+
234+ # tag in matched_tags
235+ # end
236+ # end
237237end
0 commit comments