New outbox post: Raise error if federation disabled but remote recipients found

This commit is contained in:
fr33domlover 2019-04-18 11:43:33 +00:00
parent f37b9b3f52
commit b8c669f6fc

View file

@ -417,6 +417,9 @@ handleOutboxNote host (Note mluNote luAttrib aud muParent muContext mpublished c
uContext <- fromMaybeE muContext "Note without context"
recips <- nonEmptyE (concatRecipients aud) "Note without recipients"
(mparent, localRecips, mticket, remoteRecips) <- parseRecipsContextParent recips uContext muParent
federation <- getsYesod $ appFederation . appSettings
unless (federation || null remoteRecips) $
throwE "Federation disabled, but remote recipients specified"
result <- lift $ try $ runDB $ (either abort return =<<) . runExceptT $ do
(pid, shrUser) <- verifyIsLoggedInUser luAttrib "Note attributed to different actor"
(did, meparent, mcollections) <- case mticket of
@ -479,6 +482,8 @@ handleOutboxNote host (Note mluNote luAttrib aud muParent muContext mpublished c
return (did, meparent, Nothing)
(lmid, obid, doc) <- lift $ insertMessage luAttrib shrUser pid uContext did muParent meparent content
moreRemotes <- deliverLocal obid localRecips mcollections
unless (federation || null moreRemotes) $
throwE "Federation disabled but remote collection members found"
remotesHttp <- lift $ deliverRemoteDB obid remoteRecips moreRemotes
return (lmid, obid, doc, remotesHttp)
(lmid, obid, doc, remotesHttp) <- case result of