mirror of
https://github.com/chuot/rdio-scanner.git
synced 2026-08-14 00:43:02 -06:00
34 lines
833 B
JavaScript
34 lines
833 B
JavaScript
'use strict';
|
|
|
|
const { withFilter } = require('apollo-server-express');
|
|
|
|
module.exports = ({ pubsub }) => ({
|
|
subscribe: withFilter(
|
|
() => pubsub.asyncIterator(['rdioScannerCall']),
|
|
(payload, variables) => {
|
|
if (variables.selection) {
|
|
if (payload.rdioScannerCall) {
|
|
const call = payload.rdioScannerCall;
|
|
|
|
let selection;
|
|
|
|
try {
|
|
selection = JSON.parse(variables.selection);
|
|
|
|
} catch (err) {
|
|
return false;
|
|
}
|
|
|
|
return selection[call.system][call.talkgroup];
|
|
|
|
} else {
|
|
return false;
|
|
}
|
|
|
|
} else {
|
|
return true;
|
|
}
|
|
},
|
|
),
|
|
});
|