-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathsubscribe_device.js
56 lines (44 loc) · 1.17 KB
/
subscribe_device.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/** Don't hate me for this. Just throwing together something I can quickly run. **/
var common = require('./common')
, redis = common.redis
, program = require('commander');
program
.option('-t, --task <action>', 'Task (defaults to subscribe)')
.parse(process.argv);
var task = program.task ? program.task : 'subscribe';
var testDevice = {
user_id: 1234,
token: "999988887777",
platform: "android"
};
var testNotification = {
user_id: 1234,
data: JSON.stringify({
activity_id: 4,
message: "This is a notification!"
})
}
if (task === 'subscribe') {
(function subscribe() {
redis.lpush('yodel:subscribe', JSON.stringify(testDevice), function(err, data){
console.log('yodel:subscribe lpush data', data);
if (err) {
console.log(err);
}
process.exit(0);
});
})();
} else if (task === 'notify') {
(function notify() {
redis.lpush('yodel:notify', JSON.stringify(testNotification), function(err, data){
console.log('yodel:notify lpush data', data);
if (err) {
console.log(err);
}
process.exit(0);
});
})();
} else {
console.log("Unrecognized action");
process.exit(0);
}