From b80eb01f34115a58a65d44b39df51f499a945f41 Mon Sep 17 00:00:00 2001 From: Brad Koehn Date: Mon, 19 Feb 2018 10:17:41 -0600 Subject: [PATCH 1/2] piped bin/bundle commands to suppress warnings when run on readonly filesystems closes #7719 --- Changelog.md | 1 + script/server | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Changelog.md b/Changelog.md index d10638702..40a66b663 100644 --- a/Changelog.md +++ b/Changelog.md @@ -2,6 +2,7 @@ ## Refactor * Don't print a warning when starting the server outside a Git repo [#7712](https://github.com/diaspora/diaspora/pull/7712) +* Make script/server work on readonly filesystems [#7719](https://github.com/diaspora/diaspora/pull/7719) ## Bug fixes diff --git a/script/server b/script/server index 214377694..eb8b92294 100755 --- a/script/server +++ b/script/server @@ -99,7 +99,7 @@ fi # Setup environment if [ -z "$RAILS_ENV" ] then - RAILS_ENV=$(bin/bundle exec ruby ./script/get_config.rb server.rails_environment) + RAILS_ENV=$(bin/bundle exec ruby ./script/get_config.rb server.rails_environment | grep -vE "is not writable|as your home directory temporarily" ) on_failure "Couldn't parse config/diaspora.yml!" export RAILS_ENV fi @@ -113,7 +113,8 @@ vars=$(bin/bundle exec ruby ./script/get_config.rb \ chat=chat.enabled \ chat_server=chat.server.enabled \ chat_bosh_proxy=chat.server.bosh.proxy \ - redis_url=environment.redis + redis_url=environment.redis \ + | grep -vE "is not writable|as your home directory temporarily" ) on_failure "Couldn't parse config/diaspora.yml!" eval "$vars" @@ -170,7 +171,7 @@ then then redis_param="url: '$redis_url'" fi - if [ "$(bin/bundle exec ruby -e "require 'redis'; puts Redis.new($redis_param).ping" 2> /dev/null)" != "PONG" ] + if [ "$(bin/bundle exec ruby -e "require 'redis'; puts Redis.new($redis_param).ping" 2> /dev/null | grep -vE "is not writable|as your home directory temporarily" )" != "PONG" ] then fatal "Can't connect to redis. Please check if it's running and if environment.redis is configured correctly in config/diaspora.yml." fi From c89b2ad8096df63d2b3d4a49fde73d258221588b Mon Sep 17 00:00:00 2001 From: Benjamin Neff Date: Wed, 21 Feb 2018 03:03:52 +0100 Subject: [PATCH 2/2] Prevent duplicate mention notifications when the post is received twice closes #7721 --- Changelog.md | 1 + app/models/notifications/mentioned.rb | 5 ++++- spec/models/notifications/mentioned_spec.rb | 12 ++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Changelog.md b/Changelog.md index 40a66b663..9c9c0daf5 100644 --- a/Changelog.md +++ b/Changelog.md @@ -5,6 +5,7 @@ * Make script/server work on readonly filesystems [#7719](https://github.com/diaspora/diaspora/pull/7719) ## Bug fixes +* Prevent duplicate mention notifications when the post is received twice [#7721](https://github.com/diaspora/diaspora/pull/7721) ## Features * Add basic html5 audio/video embedding support [#6418](https://github.com/diaspora/diaspora/pull/6418) diff --git a/app/models/notifications/mentioned.rb b/app/models/notifications/mentioned.rb index d49b384d7..732cbb41e 100644 --- a/app/models/notifications/mentioned.rb +++ b/app/models/notifications/mentioned.rb @@ -18,7 +18,10 @@ module Notifications ) relevant_mentions.each do |mention| - create_notification(mention.person.owner, mention, actor).try(:email_the_user, mention, actor) + recipient = mention.person.owner + unless exists?(recipient: recipient, target: mention) + create_notification(recipient, mention, actor).try(:email_the_user, mention, actor) + end end end end diff --git a/spec/models/notifications/mentioned_spec.rb b/spec/models/notifications/mentioned_spec.rb index 90e112aa3..ca77f960f 100644 --- a/spec/models/notifications/mentioned_spec.rb +++ b/spec/models/notifications/mentioned_spec.rb @@ -51,5 +51,17 @@ describe Notifications::Mentioned do expect(TestNotification).not_to receive(:create_notification) TestNotification.notify(status_message, nil) end + + it "doesn't create notification if it already exists" do + status_message = FactoryGirl.create(:status_message, text: text_mentioning(alice), author: eve.person) + TestNotification.create( + recipient: alice, + target: Mention.where(mentions_container: status_message, person: alice.person_id).first, + actors: [status_message.author] + ) + + expect(TestNotification).not_to receive(:create_notification) + TestNotification.notify(status_message, nil) + end end end