Fix welcome message crashing server if podmin is set to invalid user.

Fixes #7363

closes #7452
This commit is contained in:
Mahonri Gibson 2017-05-11 19:38:46 +00:00 committed by Benjamin Neff
parent 02b4d3f347
commit 942e090b3a
No known key found for this signature in database
GPG key ID: 971464C3F1A90194
3 changed files with 8 additions and 0 deletions

View file

@ -8,6 +8,7 @@
* Fix first comment in mobile view with french locale [#7441](https://github.com/diaspora/diaspora/pull/7441)
* Use post page title and post author in atom feed [#7420](https://github.com/diaspora/diaspora/pull/7420)
* Handle broken public keys when receiving posts [#7448](https://github.com/diaspora/diaspora/pull/7448)
* Fix welcome message when podmin is set to an invalid username [#7452](https://github.com/diaspora/diaspora/pull/7452)
## Features

View file

@ -431,6 +431,7 @@ class User < ActiveRecord::Base
return unless AppConfig.settings.welcome_message.enabled? && AppConfig.admins.account?
sender_username = AppConfig.admins.account.get
sender = User.find_by(username: sender_username)
return if sender.nil?
conversation = sender.build_conversation(
participant_ids: [sender.person.id, person.id],
subject: AppConfig.settings.welcome_message.subject.get,

View file

@ -875,6 +875,12 @@ describe User, :type => :model do
user.send_welcome_message
expect(user.conversations.count).to eq 0
end
it "should send no welcome message if podmin is invalid" do
AppConfig.admins.account = "invalid"
user.send_welcome_message
expect(user.conversations.count).to eq 0
end
end
context "with welcome message disabled" do