mirror of
https://github.com/discourse/discourse-chat-integration.git
synced 2025-03-06 17:59:29 +00:00
FIX: don't send nil user.name for MS Teams (#131)
Because Teams rejects the request for having a JSON `null` where a string is expected.
This commit is contained in:
parent
157f3e910d
commit
fd6be34974
@ -32,7 +32,12 @@ module DiscourseChatIntegration::Provider::TeamsProvider
|
||||
|
||||
def self.get_message(post)
|
||||
display_name = "@#{post.user.username}"
|
||||
full_name = SiteSetting.enable_names ? post.user.name : ""
|
||||
full_name =
|
||||
if SiteSetting.enable_names && post.user.name.present?
|
||||
post.user.name
|
||||
else
|
||||
""
|
||||
end
|
||||
|
||||
topic = post.topic
|
||||
|
||||
|
@ -25,6 +25,18 @@ RSpec.describe DiscourseChatIntegration::Provider::TeamsProvider do
|
||||
expect(stub1).to have_been_requested.once
|
||||
end
|
||||
|
||||
describe 'with nil user.name' do
|
||||
before do
|
||||
post.user.update!(name: nil)
|
||||
end
|
||||
|
||||
it 'handles nil username correctly' do
|
||||
message = described_class.get_message(post)
|
||||
name = message[:sections].first[:facts].first[:name]
|
||||
expect(name).to eq("")
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user