draft_box 0.0.1 → 0.0.3
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1dc9cf8a9519b398b986ab18e390772663f053ce25c6869eda6a6b7fbbeb72be
|
4
|
+
data.tar.gz: 80243f6424c99fc312cb7d497b46d1b5dfa3b571683f0693901ae76b86ad49ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ebf36e1a8da2d791fae17a97d38d98eb5550cee8c82fbc1f0d32c65f431777d675d81e08ee91fffc19f31c46f4571f5cade5d75ac04e63c0719c64c0dbb7a62
|
7
|
+
data.tar.gz: e6d50e905acef3486de12c3e4c33bbab26fcd5bb91dcafc49ed16d42fb3a9e177270e4b1db8b1b3e86a8a98431b7a48678b15e819752501b9747afe160fd429d
|
@@ -9,27 +9,14 @@ module DraftBox
|
|
9
9
|
def deliver!(mail)
|
10
10
|
validate_mail!(mail)
|
11
11
|
|
12
|
-
# subject: mail.subject
|
13
|
-
# body: mail.body.to_s
|
14
|
-
# from: mail.from
|
15
|
-
# to: mail.to
|
16
|
-
# cc: mail.cc
|
17
|
-
# bcc: mail.bcc
|
18
|
-
# attachments: mail.attachments
|
19
|
-
|
20
|
-
# Attachment:
|
21
|
-
# filename: attachment.filename
|
22
|
-
# content_type: attachment.content_type
|
23
|
-
# content: attachment.body.to_s
|
24
|
-
|
25
12
|
ActiveRecord::Base.transaction do
|
26
13
|
email = DraftBox::Email.create!(
|
27
14
|
subject: mail.subject,
|
28
15
|
body: mail.parts.empty? ? mail.body.to_s : mail.parts.find { |p| p.content_type.start_with?('text/html', 'text/plain') }&.body.to_s,
|
29
16
|
from: mail.from.first,
|
30
|
-
|
31
|
-
|
32
|
-
|
17
|
+
recipients: mail.to,
|
18
|
+
carbon_copies: mail.cc || [],
|
19
|
+
blind_copies: mail.bcc || []
|
33
20
|
)
|
34
21
|
|
35
22
|
mail.attachments.each do |attachment|
|
data/lib/draft_box/version.rb
CHANGED
@@ -16,8 +16,6 @@ module Generators
|
|
16
16
|
template "attachments_migration.rb", "db/migrate/#{timestamp}_create_draft_box_attachments.rb"
|
17
17
|
end
|
18
18
|
|
19
|
-
private
|
20
|
-
|
21
19
|
def migration_version
|
22
20
|
"[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]"
|
23
21
|
end
|
@@ -30,6 +28,18 @@ module Generators
|
|
30
28
|
key_string = options[:primary_key_type]
|
31
29
|
", id: :#{key_string}" if key_string
|
32
30
|
end
|
31
|
+
|
32
|
+
def sqlite?
|
33
|
+
db_adapter.match?(/sqlite/i)
|
34
|
+
end
|
35
|
+
|
36
|
+
def mysql?
|
37
|
+
db_adapter.match?(/mysql/i)
|
38
|
+
end
|
39
|
+
|
40
|
+
def db_adapter
|
41
|
+
ActiveRecord::Base.configurations.configs_for(env_name: Rails.env, name: "primary").adapter_class.to_s
|
42
|
+
end
|
33
43
|
end
|
34
44
|
end
|
35
45
|
end
|
@@ -4,9 +4,22 @@ class CreateDraftBoxEmails < ActiveRecord::Migration<%= migration_version %>
|
|
4
4
|
t.string :subject
|
5
5
|
t.text :body
|
6
6
|
t.string :from
|
7
|
-
|
8
|
-
t.string :
|
9
|
-
t.string :
|
7
|
+
<% if mysql? -%>
|
8
|
+
t.string :recipients, default: '[]'
|
9
|
+
t.string :carbon_copies, default: '[]'
|
10
|
+
t.string :blind_copies, default: '[]'
|
11
|
+
<% elsif sqlite? %>
|
12
|
+
t.json :recipients, null: false, default: []
|
13
|
+
t.json :carbon_copies, null: false, default: []
|
14
|
+
t.json :blind_copies, null: false, default: []
|
15
|
+
t.check_constraint "JSON_TYPE(recipients) = 'array'", name: 'draft_box_emails_recipients_is_array'
|
16
|
+
t.check_constraint "JSON_TYPE(carbon_copies) = 'array'", name: 'draft_box_emails_carbon_copies_is_array'
|
17
|
+
t.check_constraint "JSON_TYPE(blind_copies) = 'array'", name: 'draft_box_emails_blind_copies_is_array'
|
18
|
+
<% else %>
|
19
|
+
t.string :recipients, array: true, default: []
|
20
|
+
t.string :carbon_copies, array: true, default: []
|
21
|
+
t.string :blind_copies, array: true, default: []
|
22
|
+
<% end -%>
|
10
23
|
|
11
24
|
t.timestamps
|
12
25
|
end
|