3 var billingService
= require('../../../services/billing-service');
5 function getOwner(uri
) {
6 return uri
.split('/', 1).shift();
9 function ProOrgStrategy() {
13 ProOrgStrategy
.prototype = {
14 preload: function(troupes
) {
16 .map(function(troupe
) {
17 if (!troupe
.uri
) return; // one-to-one
18 return getOwner(troupe
.uri
);
20 .filter(function(room
) {
21 return !!room
; // this removes the `undefined` left behind (one-to-ones)
26 .findActiveOrgPlans(uris
.toArray())
28 .then(function(subscriptions
) {
30 subscriptions
.forEach(function(subscription
) {
31 var uri
= subscription
.uri
|| '';
32 proOrgs
[uri
.toLowerCase()] = !!subscription
;
35 this.proOrgs
= proOrgs
;
39 map: function(troupe
) {
40 if (!troupe
|| !troupe
.uri
) return undefined;
42 var owner
= getOwner(troupe
.uri
).toLowerCase();
43 return this.proOrgs
[owner
];
46 name
: 'ProOrgStrategy'
49 module
.exports
= ProOrgStrategy
;