diff --git a/config/settings-default.yaml b/config/settings-default.yaml index 50ac537..f9388ca 100644 --- a/config/settings-default.yaml +++ b/config/settings-default.yaml @@ -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 diff --git a/src/Vervis/Handler/Inbox.hs b/src/Vervis/Handler/Inbox.hs index db8544c..38fe006 100644 --- a/src/Vervis/Handler/Inbox.hs +++ b/src/Vervis/Handler/Inbox.hs @@ -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 diff --git a/src/Vervis/Settings.hs b/src/Vervis/Settings.hs index 0d4a22e..5d4d5ea 100644 --- a/src/Vervis/Settings.hs +++ b/src/Vervis/Settings.hs @@ -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"