DEV: applies chat namespacing (#12)

This commit is contained in:
Joffrey JAFFEUX 2023-03-17 15:15:38 +01:00 committed by GitHub
parent 75aa595105
commit edfdc6dfae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 7 additions and 7 deletions

View File

@ -17,7 +17,7 @@ class ReviewableAiChatMessage < Reviewable
end end
def chat_message def chat_message
@chat_message ||= (target || ChatMessage.with_deleted.find_by(id: target_id)) @chat_message ||= (target || Chat::Message.with_deleted.find_by(id: target_id))
end end
def chat_message_creator def chat_message_creator

View File

@ -7,7 +7,7 @@ module ::Jobs
return if (chat_message_id = args[:chat_message_id]).blank? return if (chat_message_id = args[:chat_message_id]).blank?
chat_message = ChatMessage.find_by(id: chat_message_id) chat_message = ::Chat::Message.find_by(id: chat_message_id)
return if chat_message&.message.blank? return if chat_message&.message.blank?
DiscourseAi::ChatMessageClassificator.new( DiscourseAi::ChatMessageClassificator.new(

View File

@ -59,7 +59,7 @@ module DiscourseAi
end end
def content_of(target_to_classify) def content_of(target_to_classify)
return target_to_classify.message if target_to_classify.is_a?(ChatMessage) return target_to_classify.message if target_to_classify.is_a?(Chat::Message)
if target_to_classify.post_number == 1 if target_to_classify.post_number == 1
"#{target_to_classify.topic.title}\n#{target_to_classify.raw}" "#{target_to_classify.topic.title}\n#{target_to_classify.raw}"

View File

@ -59,7 +59,7 @@ module ::DiscourseAi
{ {
model_used: model_name, model_used: model_name,
target_id: target.id, target_id: target.id,
target_type: target.class.name, target_type: target.class.sti_name,
classification_type: classification_model.type, classification_type: classification_model.type,
classification: classifications, classification: classifications,
updated_at: DateTime.now, updated_at: DateTime.now,

View File

@ -39,7 +39,7 @@ describe DiscourseAi::Toxicity::EntryPoint do
context "when creating a chat message" do context "when creating a chat message" do
let(:public_chat_channel) { Fabricate(:chat_channel) } let(:public_chat_channel) { Fabricate(:chat_channel) }
let(:creator) do let(:creator) do
Chat::ChatMessageCreator.new( Chat::MessageCreator.new(
chat_channel: public_chat_channel, chat_channel: public_chat_channel,
user: user, user: user,
content: "This is my new test", content: "This is my new test",
@ -54,7 +54,7 @@ describe DiscourseAi::Toxicity::EntryPoint do
context "when editing a chat message" do context "when editing a chat message" do
let(:chat_message) { Fabricate(:chat_message) } let(:chat_message) { Fabricate(:chat_message) }
let(:updater) do let(:updater) do
Chat::ChatMessageUpdater.new( Chat::MessageUpdater.new(
guardian: Guardian.new(chat_message.user), guardian: Guardian.new(chat_message.user),
chat_message: chat_message, chat_message: chat_message,
new_content: "This is my updated message", new_content: "This is my updated message",

View File

@ -21,7 +21,7 @@ RSpec.describe ReviewableAiChatMessage, type: :model do
reviewable.perform(moderator, :agree_and_delete) reviewable.perform(moderator, :agree_and_delete)
expect(reviewable).to be_approved expect(reviewable).to be_approved
expect(ChatMessage.with_deleted.find_by(id: chat_message_id).deleted_at).to be_present expect(Chat::Message.with_deleted.find_by(id: chat_message_id).deleted_at).to be_present
end end
it "agree_and_restore agrees with the flag and restores the message" do it "agree_and_restore agrees with the flag and restores the message" do