@@ -13,7 +13,7 @@ defmodule GroupherServer.CMS.Delegate.ArticleCommunity do
13
13
alias Helper.Types , as: T
14
14
alias Helper.ORM
15
15
16
- alias GroupherServer.CMS . { Embeds , Community , Tag , PinnedArticle }
16
+ alias GroupherServer.CMS . { Embeds , Community , PinnedArticle }
17
17
alias GroupherServer.Repo
18
18
19
19
alias Ecto.Multi
@@ -128,47 +128,6 @@ defmodule GroupherServer.CMS.Delegate.ArticleCommunity do
128
128
defp result ( { :ok , % { mirror_target_community: result } } ) , do: result |> done ( )
129
129
defp result ( { :error , _ , result , _steps } ) , do: { :error , result }
130
130
131
- @ doc """
132
- set general tag for post / tuts ...
133
- """
134
- # check community first
135
- def set_tag ( thread , % Tag { id: tag_id } , content_id ) do
136
- with { :ok , action } <- match_action ( thread , :tag ) ,
137
- { :ok , content } <- ORM . find ( action . target , content_id , preload: :tags ) ,
138
- { :ok , tag } <- ORM . find ( action . reactor , tag_id ) do
139
- update_content_tag ( content , tag )
140
-
141
- # NOTE: this should be control by Middleware
142
- # case tag_in_community_thread?(%Community{id: communitId}, thread, tag) do
143
- # true ->
144
- # content
145
- # |> Ecto.Changeset.change()
146
- # |> Ecto.Changeset.put_assoc(:tags, content.tags ++ [tag])
147
- # |> Repo.update()
148
-
149
- # _ ->
150
- # {:error, message: "Tag,Community,Thread not match", code: ecode(:custom)}
151
- # end
152
- end
153
- end
154
-
155
- def unset_tag ( thread , % Tag { id: tag_id } , content_id ) do
156
- with { :ok , action } <- match_action ( thread , :tag ) ,
157
- { :ok , content } <- ORM . find ( action . target , content_id , preload: :tags ) ,
158
- { :ok , tag } <- ORM . find ( action . reactor , tag_id ) do
159
- update_content_tag ( content , tag , :drop )
160
- end
161
- end
162
-
163
- defp update_content_tag ( content , % Tag { } = tag , opt \\ :add ) do
164
- new_tags = if opt == :add , do: content . tags ++ [ tag ] , else: content . tags -- [ tag ]
165
-
166
- content
167
- |> Ecto.Changeset . change ( )
168
- |> Ecto.Changeset . put_assoc ( :tags , new_tags )
169
- |> Repo . update ( )
170
- end
171
-
172
131
@ doc "update isEdited meta label if needed"
173
132
# TODO: diff history
174
133
def update_edit_status ( % { meta: % Embeds.ArticleMeta { is_edited: false } = meta } = content ) do
0 commit comments