@@ -54,35 +54,23 @@ defmodule MastaniServerWeb.Resolvers.CMS do
5454 # #######################
5555 # content flag ..
5656 # #######################
57- def pin_content ( _root , ~m( id type community_id) a , % { context: % { cur_user: _user } } ) do
58- with { :ok , content } <- match_action ( type , :self ) do
59- content . target
60- |> struct ( % { id: id } )
61- |> CMS . set_community_flags ( community_id , % { pin: true } )
62- end
63- end
57+ def pin_content ( _root , ~m( id thread community_id) a , _info ) ,
58+ do: set_community_flags ( community_id , thread , id , % { pin: true } )
6459
65- def undo_pin_content ( _root , ~m( id type community_id) a , % { context: % { cur_user: _user } } ) do
66- with { :ok , content } <- match_action ( type , :self ) do
67- content . target
68- |> struct ( % { id: id } )
69- |> CMS . set_community_flags ( community_id , % { pin: false } )
70- end
71- end
60+ def undo_pin_content ( _root , ~m( id thread community_id) a , _info ) ,
61+ do: set_community_flags ( community_id , thread , id , % { pin: false } )
7262
73- def trash_content ( _root , ~m( id type community_id) a , % { context: % { cur_user: _user } } ) do
74- with { :ok , content } <- match_action ( type , :self ) do
75- content . target
76- |> struct ( % { id: id } )
77- |> CMS . set_community_flags ( community_id , % { trash: true } )
78- end
79- end
63+ def trash_content ( _root , ~m( id thread community_id) a , _info ) ,
64+ do: set_community_flags ( community_id , thread , id , % { trash: true } )
65+
66+ def undo_trash_content ( _root , ~m( id thread community_id) a , _info ) ,
67+ do: set_community_flags ( community_id , thread , id , % { trash: false } )
8068
81- def undo_trash_content ( _root , ~m ( id type community_id ) a , % { context: % { cur_user: _user } } ) do
82- with { :ok , content } <- match_action ( type , :self ) do
69+ defp set_community_flags ( community_id , thread , id , flag ) do
70+ with { :ok , content } <- match_action ( thread , :self ) do
8371 content . target
8472 |> struct ( % { id: id } )
85- |> CMS . set_community_flags ( community_id , % { trash: false } )
73+ |> CMS . set_community_flags ( community_id , flag )
8674 end
8775 end
8876
0 commit comments