From 535724234aafd90c9eac17d9998f3f1c6c6c7615 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 26 Aug 2016 18:55:10 +0200 Subject: Server: add pod created date and score to the list controller --- server/controllers/api/v1/pods.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'server/controllers') diff --git a/server/controllers/api/v1/pods.js b/server/controllers/api/v1/pods.js index 360575a0d..2bdfe0c92 100644 --- a/server/controllers/api/v1/pods.js +++ b/server/controllers/api/v1/pods.js @@ -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 +} -- cgit v1.2.3