return only active conversation messages
fixes VICE-2206 flag=react_inbox Test Plan: - Make sure you have a conversation with a deleted conversation message - Enable the react inbox FF - Navigate to the inbox - Select the converesation with the deleted conversation message - The deleted conversation message should not be present Change-Id: Ia76c54d39b605d3d59b562d329bd12b6cb0631cb Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/276913 Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> Reviewed-by: Chawn Neal <chawn.neal@instructure.com> QA-Review: Chawn Neal <chawn.neal@instructure.com> Product-Review: Chawn Neal <chawn.neal@instructure.com>
This commit is contained in:
parent
51e5cb10c8
commit
ba59372e41
|
@ -38,7 +38,7 @@ module Types
|
|||
def conversation_messages_connection(participants: nil, created_before: nil)
|
||||
load_association(:conversation_messages).then do |messages|
|
||||
Loaders::AssociationLoader.for(ConversationMessage, :conversation_message_participants).load_many(messages).then do
|
||||
messages = messages.select { |message| message.conversation_message_participants.pluck(:user_id).include?(current_user.id) }
|
||||
messages = messages.select { |message| message.conversation_message_participants.pluck(:user_id, :workflow_state).include?([current_user.id, 'active']) }
|
||||
if participants
|
||||
messages = messages.select { |message| (participants - message.conversation_message_participants.pluck(:user_id).map(&:to_s)).empty? }
|
||||
end
|
||||
|
|
|
@ -90,6 +90,13 @@ describe Types::ConversationType do
|
|||
result = conversation_type.resolve(%|conversationMessagesConnection(createdBefore: "#{Time.zone.at(float_time).iso8601}") { nodes { body } }|)
|
||||
expect(result).to include(@conversation.conversation.conversation_messages[0].body)
|
||||
end
|
||||
|
||||
it 'does not return deleted messages' do
|
||||
message = @conversation.conversation.add_message(@student, 'delete me')
|
||||
message.conversation_message_participants.where(user_id: @teacher.id).first.update!(workflow_state: 'deleted')
|
||||
result = conversation_type.resolve('conversationMessagesConnection { nodes { body } }')
|
||||
expect(result).to match_array(@conversation.conversation.conversation_messages.where.not(id: message).pluck(:body))
|
||||
end
|
||||
end
|
||||
|
||||
context 'conversationPaticipants' do
|
||||
|
|
Loading…
Reference in New Issue