Merge branch 'hotfix/21.56.9' into master
[gitter.git] / server / serializers / rest / troupes / associated-repo-strategy.js
blobdff233631a8e03a384dbfe4ea94d1e91d8fb2a44
1 'use strict';
3 var roomRepoService = require('gitter-web-rooms/lib/room-repo-service');
5 function AssociatedRepoStrategy(/*options*/) {
6   this.associatedRepos = null;
9 AssociatedRepoStrategy.prototype = {
10   preload: function(items) {
11     return roomRepoService
12       .findAssociatedGithubRepoForRooms(items.toArray())
13       .bind(this)
14       .then(function(results) {
15         this.associatedRepos = results;
16       });
17   },
19   map: function(item) {
20     return this.associatedRepos[item.id || item._id] || false;
21   },
23   name: 'AssociatedRepoStrategy'
26 module.exports = AssociatedRepoStrategy;