Fix: 同じ投稿を返信かつ参照している時、同じ投稿がcontextに複数含まれる問題 (#210)

* Add: #198 `context`のAPIについて`with_references`対応

* Fix: 同じ投稿を参照かつ返信していると、`context`に同じ投稿が複数含まれる問題
This commit is contained in:
KMY(雪あすか) 2023-11-01 10:34:28 +09:00 committed by GitHub
parent 99511ee1b5
commit 77a1cabb97
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 5 deletions

View file

@ -49,7 +49,9 @@ class Api::V1::StatusesController < Api::BaseController
loaded_descendants = cache_collection(descendants_results, Status)
loaded_references = cache_collection(references_results, Status)
unless params[:with_reference]
if params[:with_reference]
loaded_references.reject! { |status| loaded_ancestors.any? { |ancestor| ancestor.id == status.id } }
else
loaded_ancestors = (loaded_ancestors + loaded_references).uniq(&:id)
loaded_references = []
end