Merge branch 'hotfix/21.56.9' into master
[gitter.git] / server / serializers / rest / favourite-groups-for-user-strategy.js
blob8724b14382559a22eb2ef6e8e01fa39520070d22
1 'use strict';
3 var groupService = require('gitter-web-groups/lib/group-service');
5 // Based on ./server/serializers/rest/troupes/favourite-troupes-for-user-strategy.js
6 function FavouriteGroupsForUserStrategy(options) {
7 this.userId = options && (options.userId || options.currentUserId);
8 this.favs = null;
11 FavouriteGroupsForUserStrategy.prototype = {
12 preload: function() {
13 return groupService
14 .findFavouriteGroupsForUser(this.userId)
15 .bind(this)
16 .then(function(favs) {
17 this.favs = favs;
18 });
21 map: function(id) {
22 var favs = this.favs[id];
23 if (!favs) return undefined;
24 if (favs === '1') return 1000;
25 return favs;
28 name: 'FavouriteGroupsForUserStrategy'
31 module.exports = FavouriteGroupsForUserStrategy;