Merge branch 'hotfix/21.56.9' into master
[gitter.git] / server / api / v1 / groups / suggested-rooms.js
blob0caa7e4ec17e51af2639f50002e393fde72ba643
1 'use strict';
3 var groupRoomSuggestions = require('gitter-web-groups/lib/group-room-suggestions');
4 var restSerializer = require('../../../serializers/rest-serializer');
6 module.exports = {
7   index: function(req) {
8     if (!req.group) return [];
10     if (!req.user) return [];
12     var userId = req.user._id;
14     return groupRoomSuggestions
15       .findUnjoinedRoomsInGroup(req.group._id, userId)
16       .then(function(suggestions) {
17         var strategy = restSerializer.TroupeStrategy.createSuggestionStrategy();
18         return restSerializer.serialize(suggestions, strategy);
19       });
20   }