Added ability to push to all devices

James 9 年之前
父节点
当前提交
5a4ba3252b
共有 1 个文件被更改,包括 7 次插入3 次删除
  1. 7 3
      app/models/agents/pushbullet_agent.rb

+ 7 - 3
app/models/agents/pushbullet_agent.rb

@@ -24,6 +24,8 @@ module Agents
24 24
 
25 25
       If you do not select an existing device, Huginn will create a new one with the name 'Huginn'.
26 26
 
27
+      To push to all of your devices, select `All Devices` from the devices list.
28
+
27 29
       You have to provide a message `type` which has to be `note`, `link`, or `address`. The message types `checklist`, and `file` are not supported at the moment.
28 30
 
29 31
       Depending on the message `type` you can use additional fields:
@@ -71,7 +73,9 @@ module Agents
71 73
     end
72 74
 
73 75
     def complete_device_id
74
-      devices.map { |d| {text: d['nickname'], id: d['iden']} }
76
+      devices
77
+        .map { |d| {text: d['nickname'], id: d['iden']} }
78
+        .unshift(text: 'All Devices', id: '__ALL__')
75 79
     end
76 80
 
77 81
     def working?
@@ -114,14 +118,14 @@ module Agents
114 118
       end
115 119
     end
116 120
 
117
-
118 121
     def basic_auth
119 122
       {basic_auth: {username: interpolated[:api_key].presence || credential('pushbullet_api_key'), password: ''}}
120 123
     end
121 124
 
122 125
     def query_options(event)
123 126
       mo = interpolated(event)
124
-      basic_auth.merge(body: {device_iden: mo[:device_id], type: mo[:type]}.merge(payload(mo)))
127
+      dev_ident = mo[:device_id] == "__ALL__" ? '' : mo[:device_id]
128
+      basic_auth.merge(body: {device_iden: dev_ident, type: mo[:type]}.merge(payload(mo)))
125 129
     end
126 130
 
127 131
     def payload(mo)