diff --git a/spec/Main.hs b/spec/Main.hs
index 1ca278e..2db5958 100644
--- a/spec/Main.hs
+++ b/spec/Main.hs
@@ -49,7 +49,7 @@ mockedTests = do
feedTests :: Spec
feedTests =
describe "rss feed" $ do
- it "should make a feed" $ do
+ it "should make a feed using embedded guest authors" $ do
ctxt <- initFauxRequestNoCache
let wpfeed = WPFeed
"https://myurl.com/feed"
@@ -62,6 +62,19 @@ feedTests =
(renderFeedContent ctxt)
ft <- toXMLFeed (_wordpress ctxt) wpfeed
ft `shouldBe` "\n\n https://myurl.com/feed\n My Blog\n 2014-10-20T07:00:00Z\n \n https://myurl.com/2014/10/foo-bar/\n <i>Foo</i> bar\n 2014-10-20T07:00:00Z\n 2014-10-20T07:00:00Z\n summary\n This is the title: <i>Foo</i> bar\n \n Emma Goldman\n \n \n \n\n"
+{- it "should make a feed using list of author ids" $ do
+ ctxt <- initFauxRequestNoCache
+ let wpfeed = WPFeed
+ "https://myurl.com/feed"
+ "My Blog"
+ Nothing
+ Nothing
+ "https://myurl.com"
+ buildEntryLinks
+ GuestAuthorsViaReq
+ (renderFeedContent ctxt)
+ ft <- toXMLFeed (_wordpress ctxt) wpfeed
+ ft `shouldBe` "\n\n https://myurl.com/feed\n My Blog\n 2014-10-20T07:00:00Z\n \n https://myurl.com/2014/10/foo-bar/\n <i>Foo</i> bar\n 2014-10-20T07:00:00Z\n 2014-10-20T07:00:00Z\n summary\n This is the title: <i>Foo</i> bar\n \n Lucy Parsons\n \n \n Emma Goldman\n \n \n \n\n" -}
larcenyFillTests :: Spec
larcenyFillTests = do
diff --git a/src/Web/Offset/Feed.hs b/src/Web/Offset/Feed.hs
index b78248c..800a7dc 100644
--- a/src/Web/Offset/Feed.hs
+++ b/src/Web/Offset/Feed.hs
@@ -32,7 +32,7 @@ data WPFeed =
, wpGetAuthors :: WPAuthorStyle
, wpRenderEntry :: Object -> IO (Maybe T.Text) }
-data WPAuthorStyle = GuestAuthors | DefaultAuthor
+data WPAuthorStyle = GuestAuthors | GuestAuthorsViaReq | DefaultAuthor
toXMLFeed :: Wordpress b -> WPFeed -> IO T.Text
toXMLFeed wp wpFeed@(WPFeed uri title icon logo _ _ _ _) = do
@@ -101,6 +101,7 @@ toEntry wp wpFeed entry@WPEntry{..} = do
let baseEntry = makeEntry guid (TextHTML wpEntryTitle) wpEntryUpdated
authors <- case wpGetAuthors wpFeed of
GuestAuthors -> getAuthorsInline wpEntryJSON
+ GuestAuthorsViaReq -> getAuthorsViaReq wp wpEntryJSON
DefaultAuthor -> getAuthorViaReq wp wpEntryJSON
return $ baseEntry { entryPublished = Just wpEntryPublished
, entrySummary = Just (TextHTML wpEntrySummary)
@@ -166,6 +167,21 @@ getAuthorViaReq wp v =
Nothing -> return []
Just authorName ->return (maybeToList authorName)
+getAuthorsViaReq :: Wordpress b -> Object -> IO [WPPerson]
+getAuthorsViaReq wp v =
+ do let mAuthorId = parseMaybe (\obj -> obj .: "authors") v :: Maybe [Int]
+ case mAuthorId of
+ Nothing -> return []
+ Just authorIds ->
+ do let authList = map (\id -> ("include[]", tshow id)) authorIds
+ eRespError <- cachingGetRetry wp (EndpointKey ("wp/v2/authors") authList)
+ case eRespError of
+ Left _ -> return []
+ Right resp ->
+ case decodeWPResponseBody resp of
+ Nothing -> return []
+ Just list -> return list
+
entryGuid :: T.Text -> Int -> Object -> URI
entryGuid baseURI wpId wpJSON =
unsafeURI $ T.unpack $