Add settings option to disable federation

This commit is contained in:
fr33domlover 2019-03-25 00:17:24 +00:00
parent e53c056e1e
commit cdb1c8b121
3 changed files with 21 additions and 1 deletions

View file

@ -131,6 +131,14 @@ max-accounts: 3
# Federation
###############################################################################
# Whether to support federation. This includes:
#
# * Accept activities from other servers in the inbox
# * Accept activities from users in the outbox
# * Deliver local activities to other servers
federation: false
# Signing key file for signing object capabilities sent to remote users
capability-signing-key: config/capability_signing_key

View file

@ -91,8 +91,9 @@ import Vervis.ActorKey
import Vervis.Federation
import Vervis.Foundation
import Vervis.Model
import Vervis.Model.Ident
import Vervis.RemoteActorStore
import Vervis.Settings (AppSettings (appHttpSigTimeLimit))
import Vervis.Settings
getInboxR :: Handler Html
getInboxR = do
@ -129,6 +130,8 @@ getInboxR = do
postInboxR :: Handler ()
postInboxR = do
federation <- getsYesod $ appFederation . appSettings
unless federation badMethod
now <- liftIO getCurrentTime
r <- runExceptT $ getActivity now
case r of
@ -231,6 +234,8 @@ getOutboxR = error "Not implemented yet"
postOutboxR :: Handler Html
postOutboxR = do
federation <- getsYesod $ appFederation . appSettings
unless federation badMethod
((result, widget), enctype) <- runFormPost activityForm
defaultLayout $ activityWidget widget enctype
case result of

View file

@ -114,6 +114,12 @@ data AppSettings = AppSettings
-- details. If set to 'Nothing', no email will be sent.
, appMail :: Maybe MailSettings
-- | Whether to support federation. This includes:
--
-- * Accept activities from other servers in the inbox
-- * Accept activities from users in the outbox
-- * Deliver local activities to other servers
, appFederation :: Bool
-- | Signing key file for signing object capabilities sent to remote
-- users
, appCapabilitySigningKeyFile :: FilePath
@ -175,6 +181,7 @@ instance FromJSON AppSettings where
appEmailVerification <- o .:? "email-verification" .!= not defaultDev
appMail <- o .:? "mail"
appFederation <- o .:? "federation" .!= False
appCapabilitySigningKeyFile <- o .: "capability-signing-key"
appHashidsSaltFile <- o .: "hashids-salt-file"
appRejectOnMaxKeys <- o .: "reject-on-max-keys"