discourse/plugins/chat/app/models/chat/null_user.rb
Joffrey JAFFEUX 92839dc722
FIX: ensures an empty last message won't cause errors (#23647)
This would cause an error when deleting the original message of a thread, due to the non existing `last_message`. This fix is implemented using the null pattern.

Note this commit is also using this opportunity to unify naming of null objects, `Chat::DeletedUser` becomes `Chat::NullUser`, it feels better to have a name describing what is the object, instead of a name describing why this object has to be used, which can change depending on cases.
2023-09-25 12:43:04 +02:00

18 lines
270 B
Ruby

# frozen_string_literal: true
module Chat
class NullUser < User
def username
I18n.t("chat.deleted_chat_username")
end
def avatar_template
"/plugins/chat/images/deleted-chat-user-avatar.png"
end
def bot?
false
end
end
end