3 if(doc.doc_type == "PodcastUserState")
5 var subscribed_devices = [];
7 for(var n in doc.actions)
9 var action = doc.actions[n];
11 if(action.action == "subscribe")
13 subscribed_devices.push(action.device);
15 else if(action.action == "unsubscribe")
17 var index = subscribed_devices.indexOf(action.device);
18 subscribed_devices.splice(index, 1);
22 for(var n in subscribed_devices)
24 var device = subscribed_devices[n];
26 if(doc.disabled_devices && (doc.disabled_devices.indexOf(device) > -1))
31 emit([doc.podcast, doc.user, device], null);