]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/controllers/api/v1/pods.js
Server: add pod created date and score to the list controller
[github/Chocobozzz/PeerTube.git] / server / controllers / api / v1 / pods.js
index 360575a0d229694bc748bae25e90a66aca8bf691..2bdfe0c923b6c623cef73a8ae90facf4d9a8eab3 100644 (file)
@@ -17,7 +17,7 @@ const router = express.Router()
 const Pod = mongoose.model('Pod')
 const Video = mongoose.model('Video')
 
-router.get('/', listPodsUrl)
+router.get('/', listPods)
 router.post('/', validators.podsAdd, addPods)
 router.post('/makefriends',
   oAuth.authenticate,
@@ -74,11 +74,11 @@ function addPods (req, res, next) {
   })
 }
 
-function listPodsUrl (req, res, next) {
-  Pod.listOnlyUrls(function (err, podsUrlList) {
+function listPods (req, res, next) {
+  Pod.list(function (err, podsUrlList) {
     if (err) return next(err)
 
-    res.json(podsUrlList)
+    res.json(getFormatedPods(podsUrlList))
   })
 }
 
@@ -142,3 +142,15 @@ function quitFriends (req, res, next) {
     res.type('json').status(204).end()
   })
 }
+
+// ---------------------------------------------------------------------------
+
+function getFormatedPods (pods) {
+  const formatedPods = []
+
+  pods.forEach(function (pod) {
+    formatedPods.push(pod.toFormatedJSON())
+  })
+
+  return formatedPods
+}