Add GET routes for /user/tags and /user/tags/{id}

An operation that is useful for tools to be able to do is to list a
user's tags without having to pull down the entire user object (which is
likely significantly larger than the tags). This commit adds a route to
GET /user/tags, to get a list of the user's tags, as well as a GET
/user/tags/{id} to get the details of a particular tag.

This commit also includes tests for the two new routes.
This commit is contained in:
Carlo Zancanaro
2015-10-20 00:50:41 +11:00
parent c04b27ffd5
commit 4d6bd38648
4 changed files with 72 additions and 1 deletions
+8
View File
@@ -673,6 +673,14 @@ api.wrap = (user, main=true) ->
user.tags.splice to, 0, user.tags.splice(from, 1)[0]
cb? null, user.tags
getTags: (req, cb) ->
cb? null, user.tags
getTag: (req, cb) ->
tid = req.params.id
i = _.findIndex user.tags, {id: tid}
return cb?({code:404,message:i18n.t('messageTagNotFound', req.language)}) if !~i
cb? null, user.tags[i]
updateTag: (req, cb) ->
tid = req.params.id