add filter generic/is_types
[mygpo.git] / couchdb / general / _design / subscriptions / views / by_device / map.js
blob29b4ba7cafc4568d61e214437b65b5d3b66a75a5
1 function(doc)
3     if(doc.doc_type == "PodcastUserState")
4     {
5         var subscribed_devices = [];
7         for(var n in doc.actions)
8         {
9             var action = doc.actions[n];
11             if(action.action == "subscribe")
12             {
13                 subscribed_devices.push(action.device);
14             }
15             else if(action.action == "unsubscribe")
16             {
17                 var index = subscribed_devices.indexOf(action.device);
18                 subscribed_devices.splice(index, 1);
19             }
20         }
22         for(var n in subscribed_devices)
23         {
24             var device = subscribed_devices[n];
26             if(doc.disabled_devices && (doc.disabled_devices.indexOf(device) > -1))
27             {
28                 continue;
29             }
31             emit([device, doc.podcast], null);
32         }
33     }