From 5aaf2ba8a9d4714d904c252ecbcf2da323167576 Mon Sep 17 00:00:00 2001 From: fr33domlover Date: Sun, 16 Jun 2019 14:58:00 +0000 Subject: [PATCH] Rename OutboxR to SharerOutboxR, because projects will have outboxes too --- config/routes | 4 ++-- src/Vervis/API.hs | 2 +- src/Vervis/Federation.hs | 2 +- src/Vervis/Foundation.hs | 8 ++++---- src/Vervis/Handler/Inbox.hs | 24 ++++++++++++------------ src/Vervis/Handler/Person.hs | 2 +- src/Vervis/Migration.hs | 4 +++- 7 files changed, 24 insertions(+), 22 deletions(-) diff --git a/config/routes b/config/routes index 533ab2c..80e1b36 100644 --- a/config/routes +++ b/config/routes @@ -54,8 +54,8 @@ /s/#ShrIdent SharerR GET /s/#ShrIdent/inbox SharerInboxR GET POST /s/#ShrIdent/notifications NotificationsR GET POST -/s/#ShrIdent/outbox OutboxR GET POST -/s/#ShrIdent/outbox/#OutboxItemKeyHashid OutboxItemR GET +/s/#ShrIdent/outbox SharerOutboxR GET POST +/s/#ShrIdent/outbox/#OutboxItemKeyHashid SharerOutboxItemR GET /p PeopleR GET diff --git a/src/Vervis/API.hs b/src/Vervis/API.hs index c7ebd75..0b5f1c8 100644 --- a/src/Vervis/API.hs +++ b/src/Vervis/API.hs @@ -475,7 +475,7 @@ createNoteC host (Note mluNote luAttrib aud muParent muContext mpublished source route2local <- getEncodeRouteLocal obihid <- encodeKeyHashid obiid lmhid <- encodeKeyHashid lmid - let luAct = route2local $ OutboxItemR shrUser obihid + let luAct = route2local $ SharerOutboxItemR shrUser obihid luNote = route2local $ MessageR shrUser lmhid doc = activity luAct luNote update obiid [OutboxItemActivity =. PersistJSON doc] diff --git a/src/Vervis/Federation.hs b/src/Vervis/Federation.hs index 39f91a8..eaab436 100644 --- a/src/Vervis/Federation.hs +++ b/src/Vervis/Federation.hs @@ -416,7 +416,7 @@ handleSharerInbox _now shrRecip (Left pidAuthor) _raw activity = do Nothing -> throwE "Local activity: Not a valid route" Just r -> return r case route of - OutboxItemR shr obikhid -> + SharerOutboxItemR shr obikhid -> (shr,) <$> decodeKeyHashidE obikhid "Local activity: ID is invalid hashid" _ -> throwE "Local activity: Not an activity route" runDBExcept $ do diff --git a/src/Vervis/Foundation.hs b/src/Vervis/Foundation.hs index 26d573e..aefd656 100644 --- a/src/Vervis/Foundation.hs +++ b/src/Vervis/Foundation.hs @@ -284,7 +284,7 @@ instance Yesod App where (SharerInboxR shr , False) -> person shr (NotificationsR shr , _ ) -> person shr - (OutboxR shr , True) -> person shr + (SharerOutboxR shr , True) -> person shr (GroupsR , True) -> personAny (GroupNewR , _ ) -> personAny @@ -720,9 +720,9 @@ instance YesodBreadcrumbs App where PublishR -> ("Publish", Just HomeR) InboxR -> ("Inbox", Just HomeR) - OutboxR shr -> ("Outbox", Just $ SharerR shr) - OutboxItemR shr hid -> ( "#" <> keyHashidText hid - , Just $ OutboxR shr + SharerOutboxR shr -> ("Outbox", Just $ SharerR shr) + SharerOutboxItemR shr hid -> ( "#" <> keyHashidText hid + , Just $ SharerOutboxR shr ) ActorKey1R -> ("Actor Key 1", Nothing) ActorKey2R -> ("Actor Key 2", Nothing) diff --git a/src/Vervis/Handler/Inbox.hs b/src/Vervis/Handler/Inbox.hs index 259b14b..34c172a 100644 --- a/src/Vervis/Handler/Inbox.hs +++ b/src/Vervis/Handler/Inbox.hs @@ -20,9 +20,9 @@ module Vervis.Handler.Inbox , postSharerInboxR , postProjectInboxR , getPublishR - , getOutboxR - , getOutboxItemR - , postOutboxR + , getSharerOutboxR + , getSharerOutboxItemR + , postSharerOutboxR , getActorKey1R , getActorKey2R , getNotificationsR @@ -349,7 +349,7 @@ activityWidget shr widget enctype = This is a federation test page. Provide a recepient actor URI and message text, and a Create activity creating a new Note will be sent to the destination server. -
+ ^{widget} |] @@ -366,8 +366,8 @@ getPublishR = do ((_result, widget), enctype) <- runFormPost activityForm defaultLayout $ activityWidget shr widget enctype -getOutboxR :: ShrIdent -> Handler TypedContent -getOutboxR shr = do +getSharerOutboxR :: ShrIdent -> Handler TypedContent +getSharerOutboxR shr = do (total, pages, mpage) <- runDB $ do sid <- getKeyBy404 $ UniqueSharer shr p <- getValBy404 $ UniquePersonIdent sid @@ -375,7 +375,7 @@ getOutboxR shr = do countAllItems = count [OutboxItemOutbox ==. obid] selectItems off lim = selectList [OutboxItemOutbox ==. obid] [Desc OutboxItemId, OffsetBy off, LimitTo lim] getPageAndNavCount countAllItems selectItems - let here = OutboxR shr + let here = SharerOutboxR shr encodeRouteLocal <- getEncodeRouteLocal encodeRoutePageLocal <- getEncodeRoutePageLocal let pageUrl = encodeRoutePageLocal here @@ -424,8 +424,8 @@ getOutboxR shr = do diffUTCTime now defaultLayout $(widgetFile "person/outbox") -getOutboxItemR :: ShrIdent -> KeyHashid OutboxItem -> Handler TypedContent -getOutboxItemR shr obikhid = do +getSharerOutboxItemR :: ShrIdent -> KeyHashid OutboxItem -> Handler TypedContent +getSharerOutboxItemR shr obikhid = do obiid <- decodeKeyHashid404 obikhid Doc h act <- runDB $ do sid <- getKeyBy404 $ UniqueSharer shr @@ -433,11 +433,11 @@ getOutboxItemR shr obikhid = do obi <- get404 obiid unless (outboxItemOutbox obi == personOutbox p) notFound return $ persistJSONValue $ outboxItemActivity obi - let here = OutboxItemR shr obikhid + let here = SharerOutboxItemR shr obikhid provideHtmlAndAP' h act $ redirect (here, [("prettyjson", "true")]) -postOutboxR :: ShrIdent -> Handler Html -postOutboxR shrAuthor = do +postSharerOutboxR :: ShrIdent -> Handler Html +postSharerOutboxR shrAuthor = do federation <- getsYesod $ appFederation . appSettings unless federation badMethod ((result, widget), enctype) <- runFormPost activityForm diff --git a/src/Vervis/Handler/Person.hs b/src/Vervis/Handler/Person.hs index 446695f..c46fce7 100644 --- a/src/Vervis/Handler/Person.hs +++ b/src/Vervis/Handler/Person.hs @@ -141,7 +141,7 @@ getPerson shr sharer person = do , actorName = sharerName sharer , actorSummary = Nothing , actorInbox = route2local $ SharerInboxR shr - , actorOutbox = Just $ route2local $ OutboxR shr + , actorOutbox = Just $ route2local $ SharerOutboxR shr , actorFollowers = Nothing , actorPublicKeys = [ Left $ route2local ActorKey1R diff --git a/src/Vervis/Migration.hs b/src/Vervis/Migration.hs index e974882..c38ae97 100644 --- a/src/Vervis/Migration.hs +++ b/src/Vervis/Migration.hs @@ -769,7 +769,9 @@ changes hLocal ctx = } obkhidNew <- encodeKeyHashid $ E.toSqlKey $ E.fromSqlKey obidNew - let luAct = encodeRouteLocal $ OutboxItemR shrAuthor obkhidNew + let luAct = + encodeRouteLocal $ + SharerOutboxItemR shrAuthor obkhidNew act = doc luAct update obidNew [OutboxItem20190612Activity =. PersistJSON act] update talid [TicketAuthorLocal20190612Offer =. obidNew]