@@ -196,6 +196,7 @@ defmodule GroupherServer.CMS.Delegate.CiteTasks do
196
196
|> Enum . uniq ( )
197
197
end
198
198
199
+ # cite article in comment
199
200
# 在评论中引用文章
200
201
defp shape_cited_content (
201
202
% Comment { } = comment ,
@@ -208,13 +209,15 @@ defmodule GroupherServer.CMS.Delegate.CiteTasks do
208
209
comment_id: comment . id ,
209
210
block_linker: [ block_id ] ,
210
211
user_id: comment . author_id ,
212
+ # extra fields for next-step usage
211
213
# used for updating citing_count, avoid load again
212
214
cited_content: cited_article ,
213
215
# for later insert all
214
216
citing_time: comment . updated_at |> DateTime . truncate ( :second )
215
217
}
216
218
end
217
219
220
+ # cite comment in comment
218
221
# 评论中引用评论
219
222
defp shape_cited_content (
220
223
% Comment { } = comment ,
@@ -227,13 +230,15 @@ defmodule GroupherServer.CMS.Delegate.CiteTasks do
227
230
comment_id: comment . id ,
228
231
block_linker: [ block_id ] ,
229
232
user_id: comment . author_id ,
233
+ # extra fields for next-step usage
230
234
# used for updating citing_count, avoid load again
231
235
cited_content: cited_comment ,
232
236
# for later insert all
233
237
citing_time: comment . updated_at |> DateTime . truncate ( :second )
234
238
}
235
239
end
236
240
241
+ # cite article in article
237
242
# 文章之间相互引用
238
243
defp shape_cited_content ( article , % { type: :article , content: cited_article } , block_id ) do
239
244
{ :ok , thread } = thread_of_article ( article )
@@ -244,6 +249,7 @@ defmodule GroupherServer.CMS.Delegate.CiteTasks do
244
249
cited_by_type: cited_article . meta . thread ,
245
250
block_linker: [ block_id ] ,
246
251
user_id: article . author . user . id ,
252
+ # extra fields for next-step usage
247
253
# used for updating citing_count, avoid load again
248
254
cited_content: cited_article ,
249
255
# for later insert all
@@ -252,7 +258,8 @@ defmodule GroupherServer.CMS.Delegate.CiteTasks do
252
258
|> Map . put ( info . foreign_key , article . id )
253
259
end
254
260
255
- # 文章里引用评论
261
+ # cite comment in article
262
+ # 文章中引用评论
256
263
defp shape_cited_content ( article , % { type: :comment , content: cited_comment } , block_id ) do
257
264
{ :ok , thread } = thread_of_article ( article )
258
265
{ :ok , info } = match ( thread )
@@ -262,6 +269,7 @@ defmodule GroupherServer.CMS.Delegate.CiteTasks do
262
269
cited_by_type: "COMMENT" ,
263
270
block_linker: [ block_id ] ,
264
271
user_id: article . author . user . id ,
272
+ # extra fields for next-step usage
265
273
# used for updating citing_count, avoid load again
266
274
cited_content: cited_comment ,
267
275
# for later insert all
@@ -307,12 +315,6 @@ defmodule GroupherServer.CMS.Delegate.CiteTasks do
307
315
defp is_comment_link? ( url ) do
308
316
with % { query: query } <- URI . parse ( url ) do
309
317
not is_nil ( query ) and String . starts_with? ( query , "comment_id=" )
310
- # is_valid_query = not is_nil(query) and String.starts_with?(query, "comment_id=")
311
- # comment_id = URI.decode_query(query) |> Map.get("comment_id")
312
- # query_not_empty = comment_id
313
-
314
- # URI.decode_query(query) |> String.starts_with?("comment_id=")
315
- # IO.inspect(query, label: "the query")
316
318
end
317
319
end
318
320