mirror of
https://code.sup39.dev/repos/Wqawg
synced 2024-12-29 00:24:51 +09:00
C2S: Process the HTML forms in postPublishR, not postSharerOutboxR
This commit is contained in:
parent
af9f207b78
commit
b030320964
3 changed files with 26 additions and 15 deletions
|
@ -32,7 +32,7 @@
|
||||||
-- Federation
|
-- Federation
|
||||||
-- ----------------------------------------------------------------------------
|
-- ----------------------------------------------------------------------------
|
||||||
|
|
||||||
/publish PublishR GET
|
/publish PublishR GET POST
|
||||||
/inbox InboxR GET
|
/inbox InboxR GET
|
||||||
/akey1 ActorKey1R GET
|
/akey1 ActorKey1R GET
|
||||||
/akey2 ActorKey2R GET
|
/akey2 ActorKey2R GET
|
||||||
|
|
|
@ -298,6 +298,8 @@ instance Yesod App where
|
||||||
| a == resendVerifyR -> personFromResendForm
|
| a == resendVerifyR -> personFromResendForm
|
||||||
(AuthR (PluginR "account" ["verify", u, _]), False) -> personUnver u
|
(AuthR (PluginR "account" ["verify", u, _]), False) -> personUnver u
|
||||||
|
|
||||||
|
(PublishR , True) -> personAny
|
||||||
|
|
||||||
(SharerInboxR shr , False) -> person shr
|
(SharerInboxR shr , False) -> person shr
|
||||||
(NotificationsR shr , _ ) -> person shr
|
(NotificationsR shr , _ ) -> person shr
|
||||||
(SharerOutboxR shr , True) -> person shr
|
(SharerOutboxR shr , True) -> person shr
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
module Vervis.Handler.Client
|
module Vervis.Handler.Client
|
||||||
( getPublishR
|
( getPublishR
|
||||||
, postSharerOutboxR
|
, postSharerOutboxR
|
||||||
|
, postPublishR
|
||||||
|
|
||||||
, postSharerFollowR
|
, postSharerFollowR
|
||||||
, postProjectFollowR
|
, postProjectFollowR
|
||||||
|
@ -184,25 +185,24 @@ followForm = renderDivs $ (,)
|
||||||
deft = ObjURI (Authority "forge.angeley.es" Nothing) $ LocalURI "/s/fr33"
|
deft = ObjURI (Authority "forge.angeley.es" Nothing) $ LocalURI "/s/fr33"
|
||||||
|
|
||||||
activityWidget
|
activityWidget
|
||||||
:: ShrIdent
|
:: Widget -> Enctype
|
||||||
-> Widget -> Enctype
|
|
||||||
-> Widget -> Enctype
|
-> Widget -> Enctype
|
||||||
-> Widget -> Enctype
|
-> Widget -> Enctype
|
||||||
-> Widget
|
-> Widget
|
||||||
activityWidget shr widget1 enctype1 widget2 enctype2 widget3 enctype3 =
|
activityWidget widget1 enctype1 widget2 enctype2 widget3 enctype3 =
|
||||||
[whamlet|
|
[whamlet|
|
||||||
<h1>Publish a ticket comment
|
<h1>Publish a ticket comment
|
||||||
<form method=POST action=@{SharerOutboxR shr} enctype=#{enctype1}>
|
<form method=POST action=@{PublishR} enctype=#{enctype1}>
|
||||||
^{widget1}
|
^{widget1}
|
||||||
<input type=submit>
|
<input type=submit>
|
||||||
|
|
||||||
<h1>Open a new ticket
|
<h1>Open a new ticket
|
||||||
<form method=POST action=@{SharerOutboxR shr} enctype=#{enctype2}>
|
<form method=POST action=@{PublishR} enctype=#{enctype2}>
|
||||||
^{widget2}
|
^{widget2}
|
||||||
<input type=submit>
|
<input type=submit>
|
||||||
|
|
||||||
<h1>Follow a person, a projet or a repo
|
<h1>Follow a person, a projet or a repo
|
||||||
<form method=POST action=@{SharerOutboxR shr} enctype=#{enctype3}>
|
<form method=POST action=@{PublishR} enctype=#{enctype3}>
|
||||||
^{widget3}
|
^{widget3}
|
||||||
<input type=submit>
|
<input type=submit>
|
||||||
|]
|
|]
|
||||||
|
@ -218,7 +218,6 @@ getUserShrIdent = fst <$> getUser
|
||||||
|
|
||||||
getPublishR :: Handler Html
|
getPublishR :: Handler Html
|
||||||
getPublishR = do
|
getPublishR = do
|
||||||
shr <- getUserShrIdent
|
|
||||||
((_result1, widget1), enctype1) <-
|
((_result1, widget1), enctype1) <-
|
||||||
runFormPost $ identifyForm "f1" publishCommentForm
|
runFormPost $ identifyForm "f1" publishCommentForm
|
||||||
((_result2, widget2), enctype2) <-
|
((_result2, widget2), enctype2) <-
|
||||||
|
@ -226,10 +225,19 @@ getPublishR = do
|
||||||
((_result3, widget3), enctype3) <-
|
((_result3, widget3), enctype3) <-
|
||||||
runFormPost $ identifyForm "f3" followForm
|
runFormPost $ identifyForm "f3" followForm
|
||||||
defaultLayout $
|
defaultLayout $
|
||||||
activityWidget shr widget1 enctype1 widget2 enctype2 widget3 enctype3
|
activityWidget widget1 enctype1 widget2 enctype2 widget3 enctype3
|
||||||
|
|
||||||
postSharerOutboxR :: ShrIdent -> Handler Html
|
postSharerOutboxR :: ShrIdent -> Handler Html
|
||||||
postSharerOutboxR shrAuthor = do
|
postSharerOutboxR _shrAuthor = do
|
||||||
|
federation <- getsYesod $ appFederation . appSettings
|
||||||
|
unless federation badMethod
|
||||||
|
|
||||||
|
error
|
||||||
|
"ActivityPub C2S outbox POST not implemented yet, but you can public \
|
||||||
|
\activities via the /publish page"
|
||||||
|
|
||||||
|
postPublishR :: Handler Html
|
||||||
|
postPublishR = do
|
||||||
federation <- getsYesod $ appFederation . appSettings
|
federation <- getsYesod $ appFederation . appSettings
|
||||||
unless federation badMethod
|
unless federation badMethod
|
||||||
|
|
||||||
|
@ -244,13 +252,15 @@ postSharerOutboxR shrAuthor = do
|
||||||
<|> Right . Left <$> result2
|
<|> Right . Left <$> result2
|
||||||
<|> Right . Right <$> result3
|
<|> Right . Right <$> result3
|
||||||
|
|
||||||
|
shrAuthor <- getUserShrIdent
|
||||||
|
|
||||||
eid <- runExceptT $ do
|
eid <- runExceptT $ do
|
||||||
input <-
|
input <-
|
||||||
case result of
|
case result of
|
||||||
FormMissing -> throwE "Field(s) missing"
|
FormMissing -> throwE "Field(s) missing"
|
||||||
FormFailure _l -> throwE "Invalid input, see below"
|
FormFailure _l -> throwE "Invalid input, see below"
|
||||||
FormSuccess r -> return r
|
FormSuccess r -> return r
|
||||||
bitraverse publishComment (bitraverse openTicket follow) input
|
bitraverse (publishComment shrAuthor) (bitraverse (openTicket shrAuthor) (follow shrAuthor)) input
|
||||||
case eid of
|
case eid of
|
||||||
Left err -> setMessage $ toHtml err
|
Left err -> setMessage $ toHtml err
|
||||||
Right id_ ->
|
Right id_ ->
|
||||||
|
@ -266,12 +276,11 @@ postSharerOutboxR shrAuthor = do
|
||||||
setMessage "Follow request published!"
|
setMessage "Follow request published!"
|
||||||
defaultLayout $
|
defaultLayout $
|
||||||
activityWidget
|
activityWidget
|
||||||
shrAuthor
|
|
||||||
widget1 enctype1
|
widget1 enctype1
|
||||||
widget2 enctype2
|
widget2 enctype2
|
||||||
widget3 enctype3
|
widget3 enctype3
|
||||||
where
|
where
|
||||||
publishComment ((hTicket, shrTicket, prj, num), muParent, msg) = do
|
publishComment shrAuthor ((hTicket, shrTicket, prj, num), muParent, msg) = do
|
||||||
encodeRouteFed <- getEncodeRouteHome
|
encodeRouteFed <- getEncodeRouteHome
|
||||||
encodeRouteLocal <- getEncodeRouteLocal
|
encodeRouteLocal <- getEncodeRouteLocal
|
||||||
let msg' = T.filter (/= '\r') msg
|
let msg' = T.filter (/= '\r') msg
|
||||||
|
@ -303,7 +312,7 @@ postSharerOutboxR shrAuthor = do
|
||||||
, noteContent = contentHtml
|
, noteContent = contentHtml
|
||||||
}
|
}
|
||||||
ExceptT $ createNoteC hLocal note
|
ExceptT $ createNoteC hLocal note
|
||||||
openTicket ((h, shr, prj), TextHtml title, TextPandocMarkdown desc) = do
|
openTicket shrAuthor ((h, shr, prj), TextHtml title, TextPandocMarkdown desc) = do
|
||||||
encodeRouteLocal <- getEncodeRouteLocal
|
encodeRouteLocal <- getEncodeRouteLocal
|
||||||
encodeRouteFed <- getEncodeRouteFed
|
encodeRouteFed <- getEncodeRouteFed
|
||||||
local <- hostIsLocal h
|
local <- hostIsLocal h
|
||||||
|
@ -352,7 +361,7 @@ postSharerOutboxR shrAuthor = do
|
||||||
, audienceNonActors = map (encodeRouteFed h) recipsC
|
, audienceNonActors = map (encodeRouteFed h) recipsC
|
||||||
}
|
}
|
||||||
ExceptT $ offerTicketC shrAuthor summary audience offer
|
ExceptT $ offerTicketC shrAuthor summary audience offer
|
||||||
follow (uObject@(ObjURI hObject luObject), uRecip) = do
|
follow shrAuthor (uObject@(ObjURI hObject luObject), uRecip) = do
|
||||||
(summary, audience, followAP) <-
|
(summary, audience, followAP) <-
|
||||||
C.follow shrAuthor uObject uRecip False
|
C.follow shrAuthor uObject uRecip False
|
||||||
ExceptT $ followC shrAuthor summary audience followAP
|
ExceptT $ followC shrAuthor summary audience followAP
|
||||||
|
|
Loading…
Reference in a new issue