huginn_outlook_agent 0.1.11 → 0.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/huginn_outlook_agent/outlook_agent.rb +40 -5
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 24fe0cf61150cf7bb9f66c230a9180a70d671626d4e9e6e23046f86d57815535
|
4
|
+
data.tar.gz: 9fdff44f5d929f45194e494e8612a3a85cffdff187495a995f8350ee32637cd7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c4c7ce7ebb34f9ef9692b09cd2b87257f605863d8a0fd6724e96cd39c9a56f1025383d234b21fc0c19dc3b1c53c945a66e4ca1b07f548fefe76963869c8a7f9
|
7
|
+
data.tar.gz: 159070df62aa2c9fd0003cf6474a0d7ff41e0bec2b3d1ab6144c46788d8fd2b098e28ff386801a0124338687cbe5979128954bde39c502ec9b207e85e5dc9167
|
@@ -23,6 +23,8 @@ module Agents
|
|
23
23
|
|
24
24
|
`raw_email` if you want MIME format content.
|
25
25
|
|
26
|
+
`email_id` is the id of your email.
|
27
|
+
|
26
28
|
`emit_events` is for creating an event.
|
27
29
|
|
28
30
|
`type` is for the wanted action like get_new_emails / send_email.
|
@@ -113,6 +115,7 @@ module Agents
|
|
113
115
|
'refresh_token' => '',
|
114
116
|
'folder' => '',
|
115
117
|
'debug' => 'false',
|
118
|
+
'email_id' => '',
|
116
119
|
'raw_email' => 'false',
|
117
120
|
'emit_events' => 'true',
|
118
121
|
'expected_receive_period_in_days' => '2',
|
@@ -125,12 +128,13 @@ module Agents
|
|
125
128
|
form_configurable :access_token, type: :string
|
126
129
|
form_configurable :folder, type: :string
|
127
130
|
form_configurable :debug, type: :boolean
|
131
|
+
form_configurable :email_id, type: :string
|
128
132
|
form_configurable :raw_email, type: :boolean
|
129
133
|
form_configurable :emit_events, type: :boolean
|
130
134
|
form_configurable :expected_receive_period_in_days, type: :string
|
131
|
-
form_configurable :type, type: :array, values: ['get_new_emails', 'send_email']
|
135
|
+
form_configurable :type, type: :array, values: ['get_new_emails', 'send_email', 'delete_email']
|
132
136
|
def validate_options
|
133
|
-
errors.add(:base, "type has invalid value: should be 'get_new_emails', 'send_email'") if interpolated['type'].present? && !%w(get_new_emails send_email).include?(interpolated['type'])
|
137
|
+
errors.add(:base, "type has invalid value: should be 'get_new_emails', 'send_email', 'delete_email'") if interpolated['type'].present? && !%w(get_new_emails send_email delete_email).include?(interpolated['type'])
|
134
138
|
|
135
139
|
unless options['client_id'].present?
|
136
140
|
errors.add(:base, "client_id is a required field")
|
@@ -152,6 +156,10 @@ module Agents
|
|
152
156
|
errors.add(:base, "refresh_token is a required field")
|
153
157
|
end
|
154
158
|
|
159
|
+
unless options['email_id'].present? || !['delete_email'].include?(options['type'])
|
160
|
+
errors.add(:base, "email_id is a required field")
|
161
|
+
end
|
162
|
+
|
155
163
|
if options.has_key?('raw_email') && boolify(options['raw_email']).nil?
|
156
164
|
errors.add(:base, "if provided, raw_email must be true or false")
|
157
165
|
end
|
@@ -200,7 +208,7 @@ module Agents
|
|
200
208
|
|
201
209
|
if interpolated['debug'] == 'true'
|
202
210
|
log "body"
|
203
|
-
log body
|
211
|
+
log body.to_s.strip.empty? ? "empty" : body
|
204
212
|
end
|
205
213
|
|
206
214
|
end
|
@@ -275,8 +283,6 @@ module Agents
|
|
275
283
|
result = {}
|
276
284
|
result['id'] = email_id
|
277
285
|
result['raw_mail'] = Base64.encode64(response.body)
|
278
|
-
log "raw_mail"
|
279
|
-
log result['raw_mail']
|
280
286
|
|
281
287
|
return result
|
282
288
|
else
|
@@ -376,6 +382,33 @@ module Agents
|
|
376
382
|
|
377
383
|
end
|
378
384
|
|
385
|
+
def delete_email()
|
386
|
+
|
387
|
+
check_token_validity()
|
388
|
+
uri = URI.parse("https://graph.microsoft.com/v1.0/me/messages/#{interpolated['email_id']}")
|
389
|
+
request = Net::HTTP::Delete.new(uri)
|
390
|
+
request.content_type = "application/json"
|
391
|
+
request["Authorization"] = "Bearer #{interpolated['access_token']}"
|
392
|
+
|
393
|
+
req_options = {
|
394
|
+
use_ssl: uri.scheme == "https",
|
395
|
+
}
|
396
|
+
|
397
|
+
response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
|
398
|
+
http.request(request)
|
399
|
+
end
|
400
|
+
|
401
|
+
log_curl_output(response.code,response.body)
|
402
|
+
|
403
|
+
if interpolated['emit_events'] == 'true'
|
404
|
+
if response.code.to_i == 204
|
405
|
+
log "test"
|
406
|
+
create_event :payload => { 'email_id' => "#{interpolated['email_id']}", 'status' => "deleted" }
|
407
|
+
end
|
408
|
+
end
|
409
|
+
|
410
|
+
end
|
411
|
+
|
379
412
|
def trigger_action
|
380
413
|
|
381
414
|
case interpolated['type']
|
@@ -383,6 +416,8 @@ module Agents
|
|
383
416
|
get_new_emails()
|
384
417
|
when "send_email"
|
385
418
|
send_email()
|
419
|
+
when "delete_email"
|
420
|
+
delete_email()
|
386
421
|
else
|
387
422
|
log "Error: type has an invalid value (#{interpolated['type']})"
|
388
423
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: huginn_outlook_agent
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nicolas Germain
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-03-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -67,7 +67,7 @@ homepage: https://github.com/hihouhou/huginn_outlook_agent
|
|
67
67
|
licenses:
|
68
68
|
- MIT
|
69
69
|
metadata: {}
|
70
|
-
post_install_message:
|
70
|
+
post_install_message:
|
71
71
|
rdoc_options: []
|
72
72
|
require_paths:
|
73
73
|
- lib
|
@@ -83,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
83
83
|
version: '0'
|
84
84
|
requirements: []
|
85
85
|
rubygems_version: 3.3.3
|
86
|
-
signing_key:
|
86
|
+
signing_key:
|
87
87
|
specification_version: 4
|
88
88
|
summary: Write a short summary, because Rubygems requires one.
|
89
89
|
test_files:
|