Merge branch 'hotfix/21.56.9' into master
[gitter.git] / server / api / v1 / orgs / suggested-rooms.js
blobd5804ad08d8dc65409bcd89d0ac9fed3a35429c1
1 'use strict';
3 var restSerializer = require('../../../serializers/rest-serializer');
4 var util = require('util');
5 var groupRoomSuggestions = require('gitter-web-groups/lib/group-room-suggestions');
6 var groupService = require('gitter-web-groups/lib/group-service');
8 /* TODO: replace this */
9 module.exports = {
10   index: util.deprecate(function(req) {
11     if (!req.user) return [];
12     var userId = req.user._id;
14     return groupService
15       .findByUri(req.params.orgName, { lean: true })
16       .then(function(group) {
17         if (!group) return [];
19         return groupRoomSuggestions.findUnjoinedRoomsInGroup(group._id, userId);
20       })
21       .then(function(suggestions) {
22         var strategy = restSerializer.TroupeStrategy.createSuggestionStrategy();
23         return restSerializer.serialize(suggestions, strategy);
24       });
25   }, '/v1/orgs/:orgName/suggestedRooms is deprecated')