fix delete_conversations for the audit log

fixes VICE-1277
flag=none

Test Plan:
- Tests pass

Change-Id: If601bf89a9cf3efdcf68972dede4cfe8a3ac98c1
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/261910
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Rob Orton <rob@instructure.com>
QA-Review: Rob Orton <rob@instructure.com>
Product-Review: Rob Orton <rob@instructure.com>
This commit is contained in:
Matthew Lemon 2021-03-30 15:30:09 -06:00
parent e12300415c
commit 7bf1651a45
2 changed files with 6 additions and 1 deletions

View File

@ -136,7 +136,6 @@ class AuditLogFieldExtension < GraphQL::Schema::FieldExtension
next unless AuditLogFieldExtension.enabled?
mutation = field.mutation
next if mutation == Mutations::DeleteConversations
next if mutation == Mutations::AddConversationMessage
logger = Logger.new(mutation, context, arguments)

View File

@ -28,6 +28,7 @@ class Mutations::DeleteConversations < Mutations::BaseMutation
def resolve(input:)
errors = {}
context[:deleted_models] = {conversations: {}}
# rubocop:disable Style/BlockDelimiters
resolved_ids = input[:ids].map { |id|
conversation = Conversation.find_by(id: id)
@ -43,6 +44,7 @@ class Mutations::DeleteConversations < Mutations::BaseMutation
end
participant_record.remove_messages(:all)
context[:deleted_models][:conversations][conversation.id] = conversation
conversation.id
}.compact
# rubocop:enable Style/BlockDelimiters
@ -54,4 +56,8 @@ class Mutations::DeleteConversations < Mutations::BaseMutation
rescue ActiveRecord::RecordInvalid => e
errors_for(e.record)
end
def self.conversation_ids_log_entry(entry, context)
context[:deleted_models][:conversations][entry]
end
end