Skip to content

Commit

Permalink
Fix welcome message crashing server if podmin is set to invalid user.
Browse files Browse the repository at this point in the history
  • Loading branch information
mahonrig authored and SuperTux88 committed May 13, 2017
1 parent 02b4d3f commit 942e090
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,7 @@ def send_welcome_message
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,
Expand Down
6 changes: 6 additions & 0 deletions spec/models/user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -875,6 +875,12 @@
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
Expand Down

0 comments on commit 942e090

Please sign in to comment.