Fix discussion entry creation

https://gerrit.instructure.com/c/canvas-lms/+/359689/ introduced a bug
This fix should resolve the 422 while trying to create a reply

flags=none

test plan
- Create a discussion
- Try to reply
- everything should work
- play with the sort order button
- refresh
- order should be preserved

Change-Id: I24ab6b05582fc93cd390cc399d03f187a8fbf905
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/360917
Reviewed-by: Mario Hegyi <mario.hegyi@instructure.com>
QA-Review: Dora Csolakov <dora.csolakov@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Product-Review: Tamás Balogh <tamas.balogh@instructure.com>
This commit is contained in:
theo sorriaux 2024-10-24 09:19:04 +02:00 committed by Tamás Balogh
parent 520362e332
commit 8de28a8ff4
2 changed files with 1 additions and 1 deletions

View File

@ -30,6 +30,7 @@ class Mutations::UpdateDiscussionSortOrder < Mutations::BaseMutation
raise GraphQL::ExecutionError, "insufficient permission" unless discussion_topic.grants_right?(current_user, session, :read)
sort_order = input[:sort_order].to_s
sort_order = DiscussionTopicParticipant::SortOrder::DESC unless DiscussionTopicParticipant::SortOrder::TYPES.include?(sort_order)
discussion_topic.update_or_create_participant(current_user:, sort_order:)
{ discussion_topic: }

View File

@ -35,7 +35,6 @@ class DiscussionTopicParticipant < ActiveRecord::Base
after_save :check_planner_cache
validates :discussion_topic_id, :user_id, :workflow_state, :unread_entry_count, presence: true
validates :sort_order, inclusion: { in: SortOrder::TYPES }
# keeps track of the read state for the initial discussion topic text
workflow do