ish_models 0.0.33.247 → 0.0.33.249
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ish/email_template.rb +2 -1
- data/lib/office/email_action.rb +2 -0
- data/lib/office/email_conversation.rb +10 -6
- data/lib/office/email_filter.rb +23 -4
- data/lib/office/email_message.rb +20 -6
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f47c52fd484b873fc0a064472c8294063d88905d59859bc67b07542892ec273
|
4
|
+
data.tar.gz: 47cc32427afa876abc9303c9a575e8cdc97f4dd546e32221a9d880415fe04c61
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f9309759d86f3cdfedf2beb55829f3272d055afe637fa1ce5e55beedb6509a07b2a8f2faaf8679726f4fc4bdffbc5e4dfdce3488c68559a75b1d380d6551ab7a
|
7
|
+
data.tar.gz: f264d1c628f3856cbbf605f1133f0d7802fa1662028d3915a0f850f73235132f422242a5ca24e06f52cba530bff660ca8d8ffe91ef9495301df975dd622ab672
|
data/lib/ish/email_template.rb
CHANGED
@@ -45,8 +45,9 @@ class ::Ish::EmailTemplate
|
|
45
45
|
binding()
|
46
46
|
end
|
47
47
|
|
48
|
-
has_many :email_actions,
|
48
|
+
has_many :email_actions, class_name: '::Office::EmailAction'
|
49
49
|
has_many :email_contexts, class_name: '::Ish::EmailContext'
|
50
|
+
has_many :email_filters, class_name: '::Office::EmailFilter', inverse_of: :email_template
|
50
51
|
|
51
52
|
SLUG_BLANK = 'blank'
|
52
53
|
def self.blank_template
|
data/lib/office/email_action.rb
CHANGED
@@ -22,5 +22,7 @@ class Office::EmailAction
|
|
22
22
|
has_many :prev_ties, class_name: '::Office::EmailActionTie', inverse_of: :next_email_action
|
23
23
|
accepts_nested_attributes_for :ties
|
24
24
|
|
25
|
+
has_many :email_filters, class_name: 'Office::EmailFilter', inverse_of: :email_action
|
26
|
+
|
25
27
|
end
|
26
28
|
EAct = Office::EmailAction
|
@@ -32,12 +32,14 @@ class Office::EmailConversation
|
|
32
32
|
## Tested manually ok, does not pass the spec. @TODO: hire to make pass spec? _vp_ 2023-03-07
|
33
33
|
def add_tag tag
|
34
34
|
case tag.class.name
|
35
|
+
when 'Integer'
|
36
|
+
tag = WpTag.find( tag )
|
35
37
|
when 'WpTag'
|
36
|
-
;
|
38
|
+
; # tag is WpTag
|
37
39
|
when 'String'
|
38
40
|
tag = WpTag.emailtag(tag)
|
39
41
|
else
|
40
|
-
throw "#add_tag expects a WpTag or string (eg WpTag::INBOX) as the only parameter."
|
42
|
+
throw "#add_tag expects a WpTag or string (eg WpTag::INBOX) or id as the only parameter."
|
41
43
|
end
|
42
44
|
self[:wp_term_ids] = ( [ tag.id ] + self[:wp_term_ids] ).uniq
|
43
45
|
self.save!
|
@@ -45,12 +47,14 @@ class Office::EmailConversation
|
|
45
47
|
|
46
48
|
def remove_tag tag
|
47
49
|
case tag.class.name
|
48
|
-
when '
|
49
|
-
|
50
|
+
when 'Integer'
|
51
|
+
tag = WpTag.find( tag )
|
50
52
|
when 'String'
|
51
|
-
tag = WpTag.emailtag(tag)
|
53
|
+
tag = WpTag.emailtag( tag )
|
54
|
+
when 'WpTag'
|
55
|
+
; # tag is WpTag
|
52
56
|
else
|
53
|
-
throw "#remove_tag expects a WpTag or string (eg WpTag::INBOX) as the only parameter."
|
57
|
+
throw "#remove_tag expects a WpTag or string (eg WpTag::INBOX) or id as the only parameter."
|
54
58
|
end
|
55
59
|
self[:wp_term_ids] = self[:wp_term_ids] - [ tag.id ]
|
56
60
|
out = self.save!
|
data/lib/office/email_filter.rb
CHANGED
@@ -7,19 +7,38 @@ class Office::EmailFilter
|
|
7
7
|
include Mongoid::Timestamps
|
8
8
|
|
9
9
|
field :from_regex
|
10
|
+
field :from_exact
|
10
11
|
field :subject_regex
|
12
|
+
field :subject_exact
|
11
13
|
field :body_regex
|
14
|
+
field :body_exact
|
12
15
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
+
|
17
|
+
KIND_AUTORESPOND_TMPL = 'autorespond-template'
|
18
|
+
KIND_AUTORESPOND_EACT = 'autorespond-email-action'
|
19
|
+
KIND_REMOVE_TAG = 'remove-tag'
|
20
|
+
KIND_ADD_TAG = 'add-tag'
|
21
|
+
|
22
|
+
KIND_AUTORESPOND = 'autorespond' # @deprecated, DO NOT USE!
|
23
|
+
KIND_DELETE = 'delete' # @deprecated, use add-tag
|
24
|
+
KIND_SKIP_INBOX = 'skip-inbox' # @deprecated, use remove-tag
|
25
|
+
|
26
|
+
KINDS = [ nil, KIND_AUTORESPOND_TMPL, KIND_AUTORESPOND_EACT, KIND_ADD_TAG, KIND_REMOVE_TAG]
|
16
27
|
field :kind
|
17
28
|
|
18
|
-
STATE_ACTIVE
|
29
|
+
STATE_ACTIVE = 'active'
|
19
30
|
STATE_INACTIVE = 'inactive'
|
20
31
|
STATES = [ STATE_ACTIVE, STATE_INACTIVE ]
|
21
32
|
field :state, type: :string, default: STATE_ACTIVE
|
22
33
|
scope :active, ->{ where( state: STATE_ACTIVE ) }
|
23
34
|
|
35
|
+
belongs_to :email_template, class_name: 'Ish::EmailTemplate', optional: true
|
36
|
+
belongs_to :email_action, class_name: 'Office::EmailAction', optional: true
|
37
|
+
|
38
|
+
field :wp_term_id, type: :integer
|
39
|
+
def category
|
40
|
+
self.wp_term_id && WpTag.find( self.wp_term_id )
|
41
|
+
end
|
42
|
+
|
24
43
|
end
|
25
44
|
|
data/lib/office/email_message.rb
CHANGED
@@ -93,14 +93,28 @@ class Office::EmailMessage
|
|
93
93
|
## @TODO: move to email_conversation _vp_ 2023-03-24
|
94
94
|
def apply_filter filter
|
95
95
|
case filter.kind
|
96
|
-
|
97
|
-
|
98
|
-
self.conv.
|
99
|
-
|
96
|
+
|
97
|
+
when ::Office::EmailFilter::KIND_ADD_TAG
|
98
|
+
self.conv.add_tag( filter.wp_term_id )
|
99
|
+
|
100
|
+
when ::Office::EmailFilter::KIND_REMOVE_TAG
|
101
|
+
self.conv.remove_tag( filter.wp_term_id )
|
102
|
+
|
103
|
+
when ::Office::EmailFilter::KIND_AUTORESPOND_TMPL
|
100
104
|
Ish::EmailContext.create({
|
101
|
-
email_template:
|
102
|
-
|
105
|
+
email_template: filter.email_template,
|
106
|
+
lead_id: lead.id,
|
107
|
+
send_at: Time.now + 22.minutes,
|
103
108
|
})
|
109
|
+
|
110
|
+
when ::Office::EmailFilter::KIND_AUTORESPOND_EACT
|
111
|
+
::Sch.create({
|
112
|
+
email_action: filter.email_action,
|
113
|
+
state: ::Sch::STATE_ACTIVE,
|
114
|
+
lead_id: lead.id,
|
115
|
+
perform_at: Time.now + 22.minutes,
|
116
|
+
})
|
117
|
+
|
104
118
|
else
|
105
119
|
raise "unknown filter kind: #{filter.kind}"
|
106
120
|
end
|