diff options
author | Benjamin Neff <benjamin@coding4coffee.ch> | 2018-01-27 06:16:45 +0300 |
---|---|---|
committer | Dennis Schubert <mail@dennis-schubert.de> | 2018-02-02 01:37:53 +0300 |
commit | a32cac06ab5bbaa124246d0c5c85e544713f94b3 (patch) | |
tree | 9360c79494b8f1779342053d82ffa79a65ef6721 | |
parent | b9787cc632b803e776efcaf8ddf517d98334f3ee (diff) |
Retry Contact messages 20 time (about two weeks)
closes #7705
-rw-r--r-- | Changelog.md | 2 | ||||
-rw-r--r-- | app/workers/send_base.rb | 2 | ||||
-rw-r--r-- | spec/workers/send_base_spec.rb | 14 | ||||
-rw-r--r-- | spec/workers/send_private_spec.rb | 17 |
4 files changed, 27 insertions, 8 deletions
diff --git a/Changelog.md b/Changelog.md index 9b41bf961..d38b1809b 100644 --- a/Changelog.md +++ b/Changelog.md @@ -4,6 +4,8 @@ * Work on the data downloads: Fixed general layout of buttons, added a timestamp and implemented auto-deletion of old exports [#7684](https://github.com/diaspora/diaspora/pull/7684) * Increase Twitter character limit to 280 [#7694](https://github.com/diaspora/diaspora/pull/7694) * Improve password autocomplete with password managers [#7642](https://github.com/diaspora/diaspora/pull/7642) +* Removed the limit of participants in private conversations [#7705](https://github.com/diaspora/diaspora/pull/7705) +* Send blocks to the blocked persons pod for better UX [#7705](https://github.com/diaspora/diaspora/pull/7705) ## Bug fixes * Fix invite link on the contacts page when the user has no contacts [#7690](https://github.com/diaspora/diaspora/pull/7690) diff --git a/app/workers/send_base.rb b/app/workers/send_base.rb index 4e292de9b..eed2ac19c 100644 --- a/app/workers/send_base.rb +++ b/app/workers/send_base.rb @@ -9,7 +9,7 @@ module Workers protected def schedule_retry(retry_count, sender_id, obj_str, failed_urls) - if retry_count < MAX_RETRIES + if retry_count < (obj_str.start_with?("Contact") ? MAX_RETRIES + 10 : MAX_RETRIES) yield(seconds_to_delay(retry_count), retry_count) else logger.warn "status=abandon sender=#{sender_id} obj=#{obj_str} failed_urls='[#{failed_urls.join(', ')}]'" diff --git a/spec/workers/send_base_spec.rb b/spec/workers/send_base_spec.rb index c7961451b..7a3b77a98 100644 --- a/spec/workers/send_base_spec.rb +++ b/spec/workers/send_base_spec.rb @@ -8,13 +8,13 @@ describe Workers::SendBase do end it "increases the interval for each retry" do - expect(Workers::SendBase.new.send(:seconds_to_delay, 2)).to be >= 625 - expect(Workers::SendBase.new.send(:seconds_to_delay, 3)).to be >= 1_296 - expect(Workers::SendBase.new.send(:seconds_to_delay, 4)).to be >= 2_401 - expect(Workers::SendBase.new.send(:seconds_to_delay, 5)).to be >= 4_096 - expect(Workers::SendBase.new.send(:seconds_to_delay, 6)).to be >= 6_561 - expect(Workers::SendBase.new.send(:seconds_to_delay, 7)).to be >= 10_000 - expect(Workers::SendBase.new.send(:seconds_to_delay, 8)).to be >= 14_641 + (2..19).each do |count| + expect(Workers::SendBase.new.send(:seconds_to_delay, count)).to be >= ((count + 3)**4) + end + + # lets make some tests with explicit numbers to make sure the formula above works correctly + # and increases the delay with the expected result expect(Workers::SendBase.new.send(:seconds_to_delay, 9)).to be >= 20_736 + expect(Workers::SendBase.new.send(:seconds_to_delay, 19)).to be >= 234_256 end end diff --git a/spec/workers/send_private_spec.rb b/spec/workers/send_private_spec.rb index 622c1e93e..1817c5983 100644 --- a/spec/workers/send_private_spec.rb +++ b/spec/workers/send_private_spec.rb @@ -41,4 +41,21 @@ describe Workers::SendPrivate do Workers::SendPrivate.new.perform(sender_id, obj_str, targets, 9) }.to raise_error Workers::SendBase::MaxRetriesReached end + + it "retries contact entities 20 times" do + contact = Fabricate(:contact_entity, author: sender_id, recipient: alice.diaspora_handle) + obj_str = contact.to_s + targets = {"https://example.org/receive/user/guid" => "<xml>post</xml>"} + expect(DiasporaFederation::Federation::Sender).to receive(:private).with( + sender_id, obj_str, targets + ).and_return(targets).twice + + expect(Workers::SendPrivate).to receive(:perform_in).with(a_kind_of(Numeric), sender_id, obj_str, targets, 19) + Workers::SendPrivate.new.perform(sender_id, obj_str, targets, 18) + + expect(Workers::SendPrivate).not_to receive(:perform_in) + expect { + Workers::SendPrivate.new.perform(sender_id, obj_str, targets, 19) + }.to raise_error Workers::SendBase::MaxRetriesReached + end end |