ish_models 0.0.33.302 → 0.0.33.303
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/gameui/asset3d.rb +2 -0
- data/lib/iro/{option_watch.rb → alert.rb-bk} +1 -1
- data/lib/ish_models.rb +1 -1
- data/lib/office/email_message.rb +53 -16
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8b412037faff703b47b7fa0233f65fdba3a6c1172323c19fbc60ec719c180fa9
|
4
|
+
data.tar.gz: 0c68af161d244280a3cd3a109f5b880dc778c5e2ca03338222a4a1262b1461f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7199e68751b9367d9b6ca3a6c9967d8ae0aea6515869f820e34b8c7283b80939e004622f666fdf08ddc13418d7a6b2480af2dea9a399f7171d8933d3911bbd20
|
7
|
+
data.tar.gz: 1a1518f3581dd67a240cb4e333f35ba405523777f048b21e5e91bb432c84d1ed11cf4ca5832234abd213300f99eb8eaec6f81ce2900f604b56eb17f81a66322a
|
data/lib/gameui/asset3d.rb
CHANGED
@@ -8,6 +8,8 @@ class ::Gameui::Asset3d
|
|
8
8
|
include Mongoid::Paperclip
|
9
9
|
include Ish::Utils
|
10
10
|
|
11
|
+
field :filename
|
12
|
+
|
11
13
|
belongs_to :marker, class_name: 'Gameui::Marker', optional: true
|
12
14
|
belongs_to :invoice, class_name: 'Ish::Invoice', optional: true
|
13
15
|
belongs_to :email_message, class_name: 'Office::EmailMessage', optional: true, inverse_of: :asset3ds
|
data/lib/ish_models.rb
CHANGED
data/lib/office/email_message.rb
CHANGED
@@ -135,23 +135,13 @@ class Office::EmailMessage
|
|
135
135
|
# "text/calendar; charset=utf-8; method=REQUEST"
|
136
136
|
def churn_subpart part
|
137
137
|
if part.content_disposition&.include?('attachment')
|
138
|
-
|
139
|
-
;
|
138
|
+
save_attachment( part, filename: "subpart-attachment" )
|
140
139
|
else
|
141
|
-
if part.content_type.include?("multipart
|
142
|
-
part.content_type.include?("multipart/alternative")
|
143
|
-
|
140
|
+
if part.content_type.include?("multipart")
|
144
141
|
part.parts.each do |subpart|
|
145
142
|
churn_subpart( subpart )
|
146
143
|
end
|
147
144
|
else
|
148
|
-
# attachment = Office::EmailAttachment.new({
|
149
|
-
# content: part.decoded,
|
150
|
-
# content_type: part.content_type,
|
151
|
-
# email_message: self,
|
152
|
-
# })
|
153
|
-
# attachment.save
|
154
|
-
|
155
145
|
if part.content_type.include?('text/html')
|
156
146
|
self.part_html = part.decoded
|
157
147
|
|
@@ -159,15 +149,19 @@ class Office::EmailMessage
|
|
159
149
|
self.part_txt = part.decoded
|
160
150
|
|
161
151
|
elsif part.content_type.include?("text/calendar")
|
162
|
-
|
152
|
+
save_attachment( part, filename: 'subpart-calendar.ics' )
|
153
|
+
|
163
154
|
elsif part.content_type.include?("application/pdf")
|
164
|
-
|
155
|
+
save_attachment( part, filename: 'subpart.pdf' )
|
156
|
+
|
165
157
|
elsif part.content_type.include?("image/jpeg")
|
166
|
-
|
158
|
+
save_attachment( part, filename: 'subpart.jpg' )
|
159
|
+
|
167
160
|
elsif part.content_type.include?("image/png")
|
168
|
-
|
161
|
+
save_attachment( part, filename: 'subpart.png' )
|
169
162
|
|
170
163
|
else
|
164
|
+
save_attachment( part, filename: 'subpart-unspecified' )
|
171
165
|
self.logs.push "444 No action for a part with content_type #{part.content_type}"
|
172
166
|
|
173
167
|
end
|
@@ -175,6 +169,49 @@ class Office::EmailMessage
|
|
175
169
|
end
|
176
170
|
end
|
177
171
|
|
172
|
+
def save_attachment att, filename: "no-filename-specified"
|
173
|
+
content_type = att.content_type.split(';')[0]
|
174
|
+
if content_type.include? 'image'
|
175
|
+
photo = Photo.new({
|
176
|
+
content_type: content_type,
|
177
|
+
email_message_id: @message.id,
|
178
|
+
image_data: att.body.encoded,
|
179
|
+
original_filename: att.content_type_parameters[:name],
|
180
|
+
})
|
181
|
+
photo.decode_base64_image
|
182
|
+
photo.save
|
183
|
+
else
|
184
|
+
|
185
|
+
filename = CGI.escape( att.filename || filename )
|
186
|
+
attachment = Office::EmailAttachment.new({
|
187
|
+
content: att.body.decoded,
|
188
|
+
content_type: att.content_type,
|
189
|
+
email_message: @message,
|
190
|
+
filename: filename,
|
191
|
+
})
|
192
|
+
begin
|
193
|
+
attachment.save
|
194
|
+
rescue Encoding::UndefinedConversionError
|
195
|
+
@message.logs.push "Could not save an attachment"
|
196
|
+
@message.save
|
197
|
+
end
|
198
|
+
|
199
|
+
sio = StringIO.new att.body.decoded
|
200
|
+
File.open("/tmp/#{filename}", 'w:UTF-8:ASCII-8BIT') do |f|
|
201
|
+
f.puts(sio.read)
|
202
|
+
end
|
203
|
+
asset3d = ::Gameui::Asset3d.new({
|
204
|
+
email_message: @message,
|
205
|
+
filename: filename,
|
206
|
+
object: File.open("/tmp/#{filename}"),
|
207
|
+
})
|
208
|
+
if !asset3d.save
|
209
|
+
@message.logs.push "Could not save an asset3d"
|
210
|
+
@message.save
|
211
|
+
end
|
212
|
+
|
213
|
+
end
|
214
|
+
end
|
178
215
|
|
179
216
|
def body_sanitized
|
180
217
|
ActionView::Base.full_sanitizer.sanitize( part_html||'' ).squish
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ish_models
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.33.
|
4
|
+
version: 0.0.33.303
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- piousbox
|
@@ -191,7 +191,7 @@ files:
|
|
191
191
|
- lib/gameui/map.rb
|
192
192
|
- lib/gameui/map_bookmark.rb
|
193
193
|
- lib/gameui/marker.rb
|
194
|
-
- lib/iro/
|
194
|
+
- lib/iro/alert.rb-bk
|
195
195
|
- lib/ish/cache_key.rb
|
196
196
|
- lib/ish/configuration.rb
|
197
197
|
- lib/ish/crawler.rb
|