Isambard
(Isambard)
3월 13, 2024, 10:39오후
1
어떤 유효성 검사를 우회할 수 있으며, 어떻게 해야 하나요? API를 사용하여 게시글을 작성하려는데 다음과 같은 오류가 발생하고 있습니다:
엔트로피가 너무 낮음
토픽이 너무 짧음
본문이 너무 유사함
문제는 다른 어떤 검사에 걸릴지 예측하기 어렵다는 점입니다. 그래서 오류가 하나만 나와도 바로 중단하고 다시 실행하게 됩니다.
pfaffman
(Jay Pfaffman)
3월 14, 2024, 7:03오후
2
기존 데이터베이스에서 몇 개 이상의 게시물을 가져오는 경우 마이그레이션 스크립트를 사용해야 합니다.
Ruby에서는 skip_validations 매개변수를 전달할 수 있지만, API를 통해 전달할 수 있는지는 알 수 없습니다.
하지만 정말로 서로 다른 문자가 매우 적고 다른 게시물과 거의 동일한 짧은 게시물들을 대량으로 생성하고 싶으신가요? 이를 변경할 수 있는 사이트 설정이 있습니다. 해당 단어(entropy, minimum post length, min title similar length 또는 allow duplicate titles)로 사이트 설정을 검색해 보시면 됩니다.
네, 그렇게 하면 작동할 것입니다 (예를 들어 WP-Discourse에서 이를 사용함)
post_revision
end
def find_latest_post_revision_from_params
post = find_post_from_params
finder = PostRevision.where(post_id: post.id).order(:number)
finder = finder.where(hidden: false) unless guardian.is_staff?
post_revision = finder.last
raise Discourse::NotFound unless post_revision
post_revision.post = post
guardian.ensure_can_see!(post_revision)
post_revision
end
def find_post_revision_from_topic_id
post =
Post.find_by(topic_id: params[:topic_id].to_i, post_number: (params[:post_number] || 1).to_i)
Isambard
(Isambard)
3월 19, 2024, 12:12오전
4
skip validations에 버그가 있는 것 같습니다.
skip validations를 사용하여 주제를 생성하면, 이는 정상적으로 작동하며 일반적으로 해당 권한이 없는 사용자도 카테고리에서 주제를 생성할 수 있습니다.
그러나 동일한 주제에 답글을 작성하려고 하면 검증 체크가 건너뛰지지 않아 게시글 생성이 실패합니다.
정확히 어떤 POST 유효성 검사를 말씀하시는 건지 구체적으로 설명해 주시겠어요? 어떤 오류가 발생하나요?
simon
3월 20, 2024, 10:46오후
6
정말 그런가요? 제 이해로는 post_creator.rb 하단 옵션 섹션에 명시된 대로 skip_validations는 그 이름이 의미하는 바를 수행합니다:
# :raw_html - Perform no processing
# :raw_email - Imported from an email
# via_email - Mark this post as arriving via email
# raw_email - Full text of arriving email (to store)
# action_code - Describes a small_action post (optional)
# skip_jobs - Don't enqueue jobs when creation succeeds. This is needed if you
# wrap `PostCreator` in a transaction, as the sidekiq jobs could
# dequeue before the commit finishes. If you do this, be sure to
# call `enqueue_jobs` after the transaction is committed.
# hidden_reason_id - Reason for hiding the post (optional)
# skip_validations - Do not validate any of the content in the post
# skip_rate_limits - Do not apply the author's post rate limits
# skip_staff_author_pm_membership_sync - Do not add the post author to private message allowed users when a staff guardian authorizes the post
# draft_key - the key of the draft we are creating (will be deleted on success)
# advance_draft - Destroy draft after creating post or topic
# silent - Do not update topic stats and fields like last_post_user_id
#
# When replying to a topic:
# topic_id - topic we're replying to
# reply_to_post_number - post number we're replying to
#
주로 사이트 설정을 통해 추가되는 제약 조건을 무시하는 데 사용됩니다. 예를 들어:
최소 글자 수
본문 최소 엔트로피
최소 주제 제목 길이
…
게시물 작성 속도 제한도 무시하는 데 사용된다고 생각합니다.
권한이 없는 카테고리에서 사용자가 주제를 만들 수 있게 해주는 기능이라고는 생각하지 않았습니다.