From 0c280c7af6bd42e459eaeb275f1d1217d37859a6 Mon Sep 17 00:00:00 2001 From: fr33domlover Date: Mon, 1 Apr 2019 23:38:44 +0000 Subject: [PATCH] Add setting that says how much time to keep retrying activity delivery --- config/settings-default.yaml | 9 ++++++++- src/Vervis/Settings.hs | 16 ++++++++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/config/settings-default.yaml b/config/settings-default.yaml index f9388ca..d2f38a4 100644 --- a/config/settings-default.yaml +++ b/config/settings-default.yaml @@ -131,7 +131,6 @@ max-accounts: 3 # Federation ############################################################################### - # Whether to support federation. This includes: # # * Accept activities from other servers in the inbox @@ -148,3 +147,11 @@ hashids-salt-file: config/hashids_salt # Whether to reject an HTTP signature when we want to insert a new key or usage # record but reached the limit setting reject-on-max-keys: true + +# The duration of time during which a remote actor is unreachable and we +# periodically retry to deliver them activities. After that period of time, we +# stop trying to deliver and we remove them from follower lists of local +# actors. +drop-delivery-after: + amount: 25 + unit: weeks diff --git a/src/Vervis/Settings.hs b/src/Vervis/Settings.hs index 5d4d5ea..769b29d 100644 --- a/src/Vervis/Settings.hs +++ b/src/Vervis/Settings.hs @@ -31,8 +31,10 @@ import Control.Exception (throw) import Data.Aeson (Result (..), fromJSON, withObject, (.!=), (.:?)) import Data.FileEmbed (embedFile) -import Data.Time.Interval (TimeInterval) -import Data.Time.Interval.Aeson (interval) +import Data.Time.Clock +import Data.Time.Interval +import Data.Time.Interval.Aeson +import Data.Time.Units import Data.Yaml (decodeEither') import Database.Persist.Postgresql (PostgresConf) import Language.Haskell.TH.Syntax (Exp, Name, Q) @@ -139,6 +141,11 @@ data AppSettings = AppSettings -- over HTTP, which possibly means we have to do more HTTP key fetching, -- and the target server gets a higher load of key fetch GET requests. , appRejectOnMaxKeys :: Bool + -- | The duration of time during which a remote actor is unreachable and + -- we periodically retry to deliver them activities. After that period of + -- time, we stop trying to deliver and we remove them from follower lists + -- of local actors. + , appDropDeliveryAfter :: NominalDiffTime } instance FromJSON AppSettings where @@ -185,8 +192,13 @@ instance FromJSON AppSettings where appCapabilitySigningKeyFile <- o .: "capability-signing-key" appHashidsSaltFile <- o .: "hashids-salt-file" appRejectOnMaxKeys <- o .: "reject-on-max-keys" + appDropDeliveryAfter <- ndt <$> o .: "drop-delivery-after" return AppSettings {..} + where + toSeconds :: TimeInterval -> Second + toSeconds = toTimeUnit + ndt = fromIntegral . toSeconds . interval -- | Settings for 'widgetFile', such as which template languages to support and -- default Hamlet settings.