omah 0.9.0 → 0.9.1
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
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/omah.rb +76 -76
- metadata +4 -24
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5775bda4b445e69339cecb256cb6535d64a2c82e00102a56020a45d3c4baad59
|
4
|
+
data.tar.gz: 426d302bd522404ed6fadcd9fedede85037e02d490198f2059c3174b657993e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d3d9080cb5c4f92bbbd1990b1a65b25efc3a87a89847aa5c64809cbb943ec17995080793140873b4b5537f9ab118a6021627b1d114829de1e736f96390a81c1d
|
7
|
+
data.tar.gz: 86e1c0f6c3e8271d3cdc8ec26b665f5f91ab8b30478d3c8b8e2ff90765d56d524106cfb3d250fca01374c8c9b553deeaa8afcfc2c5c608b235049ab1d39f6f11
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/omah.rb
CHANGED
@@ -3,7 +3,6 @@
|
|
3
3
|
# file: omah.rb
|
4
4
|
# title: Offline Mail Helper
|
5
5
|
|
6
|
-
require 'zip'
|
7
6
|
require 'nokorexi'
|
8
7
|
require 'dynarex-daily'
|
9
8
|
require 'novowels'
|
@@ -49,7 +48,7 @@ class Omah
|
|
49
48
|
|
50
49
|
FileX.chdir @filepath_user
|
51
50
|
|
52
|
-
dailyfile = 'dynarexdaily.xml'
|
51
|
+
dailyfile = File.join(@filepath_user, 'dynarexdaily.xml')
|
53
52
|
|
54
53
|
x = if FileX.exists? dailyfile then dailyfile
|
55
54
|
|
@@ -57,18 +56,20 @@ class Omah
|
|
57
56
|
|
58
57
|
'messages[date, prev_date, next_date]/message(msg_id, tags, from, ' + \
|
59
58
|
'to, subject, date, txt_filepath, html_filepath, attachment1, ' + \
|
60
|
-
'attachment2, attachment3)'
|
59
|
+
'attachment2, attachment3, attachments)'
|
61
60
|
|
62
61
|
end
|
63
62
|
|
64
63
|
puts 'Omah::initialize before DynarexDaily' if @debug
|
65
|
-
@dd = DynarexDaily.new x, dir_archive: :yearly
|
64
|
+
@dd = DynarexDaily.new x, dir_archive: :yearly, debug: @debug
|
66
65
|
puts 'Omah::initialize after DynarexDaily' if @debug
|
67
66
|
# is it a new day?
|
68
67
|
|
69
68
|
if @dd.records.empty? then
|
70
69
|
|
71
|
-
date_yesterday = (
|
70
|
+
date_yesterday = File.join(@filepath_user,
|
71
|
+
(Date.today - 1).strftime("%Y/%b/%d").downcase)
|
72
|
+
|
72
73
|
@dd.prev_date = File.join(@webpath_user, date_yesterday)
|
73
74
|
|
74
75
|
# add the next_day field value to the previous day file
|
@@ -110,58 +111,60 @@ class Omah
|
|
110
111
|
|
111
112
|
def store(messages)
|
112
113
|
|
113
|
-
messages.each.with_index do |
|
114
|
-
|
115
|
-
|
116
|
-
subject = msg[:subject] || ''
|
114
|
+
messages.each.with_index do |x,i|
|
115
|
+
|
116
|
+
email, msg = x
|
117
117
|
|
118
|
-
|
118
|
+
begin
|
119
|
+
|
120
|
+
puts "i: %d msg: %s" % [i, msg] if @debug
|
121
|
+
subject = msg[:subject] || ''
|
122
|
+
|
123
|
+
title = subject.gsub(/\W+/,'-')[0,30].sub(/^-/,'').sub(/-$/,'')
|
119
124
|
|
120
|
-
|
125
|
+
a = @dd.all.select {|x| x.subject == subject}
|
121
126
|
|
122
|
-
|
127
|
+
ordinal = a.any? ? '.' + a.length.to_s : ''
|
123
128
|
|
124
|
-
|
129
|
+
x_file = title + ordinal
|
125
130
|
|
126
|
-
|
131
|
+
id = msg[:msg_id]
|
127
132
|
|
128
|
-
|
133
|
+
next if @dd.find_by_msg_id id
|
129
134
|
|
130
|
-
|
135
|
+
path = archive()
|
131
136
|
|
132
|
-
|
137
|
+
x_filepath = File.join(path, x_file)
|
133
138
|
|
134
|
-
|
135
|
-
|
136
|
-
|
139
|
+
puts 'FileX.pwd ' + FileX.pwd if @debug
|
140
|
+
puts 'Omah::store before mkdir_p path: ' + path.inspect if @debug
|
141
|
+
FileX.mkdir_p path
|
137
142
|
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
143
|
+
if msg[:raw_source] then
|
144
|
+
FileX.write File.join(@filepath_user, x_filepath + '.eml'), \
|
145
|
+
msg[:raw_source]
|
146
|
+
end
|
142
147
|
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
148
|
+
header = %i(from to subject).inject({}) {|r,x| r.merge(x => msg[x]) }
|
149
|
+
Kvx.new(header).save File.join(@filepath_user, x_filepath + '.kvx')
|
150
|
+
|
151
|
+
txt_filepath = x_filepath + '.txt'
|
152
|
+
FileX.write File.join(@filepath_user, txt_filepath), \
|
153
|
+
text_sanitiser(msg[:body_text].to_s)
|
149
154
|
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
parts_path = []
|
155
|
-
|
156
|
-
# save the attachments
|
157
|
-
if msg[:attachments].length > 0 then
|
155
|
+
html_filepath = x_filepath + '.html'
|
156
|
+
FileX.write File.join(@filepath_user, html_filepath), \
|
157
|
+
html_sanitiser(msg[:body_html].to_s)
|
158
158
|
|
159
|
-
|
160
|
-
FileX.mkdir_p attachment_path
|
159
|
+
parts_path = []
|
161
160
|
|
162
|
-
|
161
|
+
# save the attachments
|
162
|
+
if msg[:attachments].length > 0 then
|
163
|
+
|
164
|
+
attachment_path = File.join(path, title + ordinal)
|
165
|
+
FileX.mkdir_p attachment_path
|
163
166
|
|
164
|
-
msg[:attachments].each.with_index do |x, i|
|
167
|
+
msg[:attachments][0..2].each.with_index do |x, i|
|
165
168
|
|
166
169
|
name, buffer = x
|
167
170
|
parts_path[i] = File.join(attachment_path, name.gsub('/',''))
|
@@ -171,39 +174,28 @@ class Omah
|
|
171
174
|
puts ($!)
|
172
175
|
end
|
173
176
|
|
174
|
-
end
|
175
|
-
|
176
|
-
else
|
177
|
+
end
|
177
178
|
|
178
|
-
|
179
|
-
|
180
|
-
zipfile = File.join(@filepath_user, attachment_path,
|
181
|
-
title[0,12].downcase + '.zip')
|
182
|
-
parts_path[0] = zipfile
|
183
|
-
|
184
|
-
FileX.zip zipfile, msg[:attachments]
|
185
|
-
|
186
|
-
end
|
187
|
-
|
179
|
+
h[:attachments] = msg[:attachments].map(&:first)
|
188
180
|
|
189
|
-
end
|
190
|
-
|
191
|
-
msg.delete :attachments
|
192
|
-
|
193
|
-
h = msg.merge(txt_filepath: txt_filepath, \
|
194
|
-
html_filepath: html_filepath)
|
195
|
-
parts_path.each.with_index do |path, i|
|
196
|
-
h.merge!("attachment#{i+1}" => @webpath_user + '/' + path)
|
197
|
-
end
|
198
|
-
|
199
|
-
if parts_path.any? then
|
200
|
-
|
201
|
-
attachments = parts_path.map do |path|
|
202
|
-
"<li><a href='%s'>%s</a></li>" % [@webpath_user + '/' + path,
|
203
|
-
File.basename(path)]
|
204
181
|
end
|
205
182
|
|
183
|
+
msg.delete :attachments
|
184
|
+
|
185
|
+
h = msg.merge(txt_filepath: txt_filepath, \
|
186
|
+
html_filepath: html_filepath)
|
187
|
+
parts_path.each.with_index do |path, i|
|
188
|
+
h.merge!("attachment#{i+1}" => @webpath_user + '/' + path)
|
189
|
+
end
|
206
190
|
|
191
|
+
if parts_path.any? then
|
192
|
+
|
193
|
+
attachments = parts_path.map do |path|
|
194
|
+
"<li><a href='%s'>%s</a></li>" % [@webpath_user + '/' + path,
|
195
|
+
File.basename(path)]
|
196
|
+
end
|
197
|
+
|
198
|
+
|
207
199
|
html_page= %Q(
|
208
200
|
<html>
|
209
201
|
<head>
|
@@ -221,15 +213,23 @@ html_page= %Q(
|
|
221
213
|
</html>
|
222
214
|
)
|
223
215
|
|
224
|
-
|
225
|
-
|
226
|
-
|
216
|
+
FileX.write File.join(attachment_path, 'index.html'), html_page
|
217
|
+
h[:html_filepath] = File.join(attachment_path, 'index.html')
|
218
|
+
end
|
227
219
|
|
228
|
-
|
220
|
+
h[:link] = File.join(@url_base, @webpath_user, html_filepath)
|
229
221
|
|
230
|
-
|
222
|
+
@plugins.each {|x| x.on_newmessage(h) if x.respond_to? :on_newmessage }
|
223
|
+
|
224
|
+
@dd.create h
|
225
|
+
|
231
226
|
|
232
|
-
|
227
|
+
# remove the message from the server
|
228
|
+
#jr250918 email.delete
|
229
|
+
|
230
|
+
rescue
|
231
|
+
puts 'Omah::store warning: ' + ($!).inspect
|
232
|
+
end
|
233
233
|
|
234
234
|
end
|
235
235
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omah
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -30,7 +30,7 @@ cert_chain:
|
|
30
30
|
QYtaxpGWTpAPjszaFSAGnt9wrzAMCFPhpqXanwuDYpQ0rmo/GgWyJNEJuUgvMZBi
|
31
31
|
WfE=
|
32
32
|
-----END CERTIFICATE-----
|
33
|
-
date: 2018-
|
33
|
+
date: 2018-09-26 00:00:00.000000000 Z
|
34
34
|
dependencies:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: dynarex-daily
|
@@ -41,7 +41,7 @@ dependencies:
|
|
41
41
|
version: '0.4'
|
42
42
|
- - ">="
|
43
43
|
- !ruby/object:Gem::Version
|
44
|
-
version: 0.4.
|
44
|
+
version: 0.4.1
|
45
45
|
type: :runtime
|
46
46
|
prerelease: false
|
47
47
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -51,27 +51,7 @@ dependencies:
|
|
51
51
|
version: '0.4'
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.4.
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: rubyzip
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '1.2'
|
62
|
-
- - ">="
|
63
|
-
- !ruby/object:Gem::Version
|
64
|
-
version: 1.2.1
|
65
|
-
type: :runtime
|
66
|
-
prerelease: false
|
67
|
-
version_requirements: !ruby/object:Gem::Requirement
|
68
|
-
requirements:
|
69
|
-
- - "~>"
|
70
|
-
- !ruby/object:Gem::Version
|
71
|
-
version: '1.2'
|
72
|
-
- - ">="
|
73
|
-
- !ruby/object:Gem::Version
|
74
|
-
version: 1.2.1
|
54
|
+
version: 0.4.1
|
75
55
|
- !ruby/object:Gem::Dependency
|
76
56
|
name: nokorexi
|
77
57
|
requirement: !ruby/object:Gem::Requirement
|
metadata.gz.sig
CHANGED
Binary file
|