wco_models 3.1.0.304 → 3.1.0.305

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: 87541daeb7455882c94e744cf11f35ac8a491c2a7367e59bb666cb8230473613
4
- data.tar.gz: 1a421dd9461abd591b248c6b9d1eeaadb6f05e3146a9e8420f35c35504d278c4
3
+ metadata.gz: 9ab5f3e9735c73de3708a8b0cedec3bba5b93a1f6c693396d6f6b492c5639702
4
+ data.tar.gz: 94708879c3fc160e214afe8522e9bc792fdf046fa903f9c27151e237419189d3
5
5
  SHA512:
6
- metadata.gz: 03f99e4c551e579c2cdc8ec4436ffb0ec66b4af7c812424bc7ed027d950b40b7fde8efbdf174bd64b9f7084bf4cefb8b97266da6bdb535ae3ef26972cdf9496f
7
- data.tar.gz: df84c4aaa5f7f63c6fa5fa589cb7a4e596e70cceb661881c1900517e3ef6ca276524ea56c8d6f0f4cfe4d598534e57800ad800660b280330c0673272d495ae38
6
+ metadata.gz: 0d9e765a2b3b61a7641704fe779b297191fa7a8d2c167f5e7163f51d2a8fd0696839620e2864ad557bbbc0fa7b8b26366023f85c797ff0bb52c36b3bd59ec27f
7
+ data.tar.gz: 453ab1dd3bd2f1acc9239445522836ce18064a6fbb16b54499db401044e86545702f344d0c1fb1e2099b911e19dbe4386d2b2828ccc237d2a0e3a982476ae5ec
@@ -6,6 +6,7 @@ class Wco::Photo
6
6
  include Mongoid::Document
7
7
  include Mongoid::Timestamps
8
8
  include Mongoid::Paperclip
9
+ include Mongoid::Paranoia
9
10
  include Wco::Utils
10
11
  store_in collection: 'photos'
11
12
 
@@ -51,7 +51,7 @@ class WcoEmail::Context
51
51
  elsif tmpl&.from_email
52
52
  return tmpl.from_email
53
53
  else
54
- return DEFAULT_FROM_EMAIL
54
+ return 'no-reply@wasya.co' ## DEFAULT_FROM_EMAIL
55
55
  end
56
56
  end
57
57
  index({ from_email: -1 })
@@ -11,17 +11,17 @@ class WcoEmail::EmailFilterCondition
11
11
  FIELD_BODY_PLAIN = 'body-plain'
12
12
  FIELD_FROM = 'from'
13
13
  FIELD_LEADSET = 'from-leadset'
14
- FIELD_NOT_TAGGED = 'leadset-not-tagged'
15
14
  FIELD_SUBJECT = 'subject'
16
- FIELD_TAGGED = 'leadset-tagged'
15
+ FIELD_TAGGED = 'leadset-tagged' ## either lead or leadset, actually
16
+ FIELD_NOT_TAGGED = 'leadset-not-tagged' ## either lead or leadset, actually
17
17
  FIELD_TO_OR_CC = 'to-or-cc'
18
18
  FIELD_OPTS = [
19
19
  FIELD_BODY, FIELD_BODY_PLAIN,
20
20
  FIELD_FROM,
21
21
  FIELD_LEADSET,
22
- FIELD_NOT_TAGGED,
23
22
  FIELD_SUBJECT,
24
23
  FIELD_TAGGED,
24
+ FIELD_NOT_TAGGED,
25
25
  FIELD_TO_OR_CC,
26
26
  ];
27
27
  field :field
@@ -49,10 +49,11 @@ class WcoEmail::EmailFilterCondition
49
49
 
50
50
  index({ email_filter_id: 1, field: 1, operator: 1, value: 1 }, unique: true )
51
51
 
52
- def apply leadset:, message:
52
+ def apply lead:, leadset:, message:
53
53
  cond = self
54
54
  reason = nil
55
55
  case cond.field
56
+
56
57
  ## from match-i <value>
57
58
  when WcoEmail::EmailFilterCondition::FIELD_FROM
58
59
  if cond.operator == WcoEmail::EmailFilterCondition::OPERATOR_MATCH
@@ -60,7 +61,35 @@ class WcoEmail::EmailFilterCondition
60
61
  reason = "#{email_skip_filter ? 'skip_' : ''}condition from match-i `#{value}`"
61
62
  end
62
63
  end
63
- end
64
+
65
+ when WcoEmail::EmailFilterCondition::FIELD_TAGGED
66
+ ## cond.operator should eql OPERATOR__ID but I don't check b/c if its slug, it should work also.
67
+ tag = Wco::Tag.find( cond.value ) rescue nil
68
+ tag ||= Wco::Tag.where( slug: cond.value ).first
69
+ if tag
70
+ if leadset.tags.include?( tag ) ||
71
+ lead.tags.include?( tag )
72
+
73
+ reason = "#{email_skip_filter ? 'skip_' : ''}condition TAGGED `#{tag.slug}`"
74
+
75
+ end
76
+ end
77
+
78
+ when WcoEmail::EmailFilterCondition::FIELD_NOT_TAGGED
79
+ ## cond.operator should eql OPERATOR__ID but I don't check b/c if its slug, it should work also.
80
+ tag = Wco::Tag.find( cond.value ) rescue nil
81
+ tag ||= Wco::Tag.where( slug: cond.value ).first
82
+ if tag
83
+ if !leadset.tags.include?( tag ) &&
84
+ !lead.tags.include?( tag )
85
+
86
+ reason = "#{email_skip_filter ? 'skip_' : ''}condition NOT_TAGGED `#{tag.slug}`"
87
+
88
+ end
89
+ end
90
+
91
+ end ## end case
92
+
64
93
  # when WcoEmail::FIELD_LEADSET
65
94
  # if cond.operator == WcoEmail::OPERATOR_NOT_HAS_TAG
66
95
  # this_tag = Wco::Tag.find cond.value
@@ -88,7 +88,8 @@ class WcoEmail::Message
88
88
 
89
89
  def apply_filter_action action
90
90
  message = self
91
- aject = action.aject
91
+ aject = action.aject
92
+
92
93
  case action.kind
93
94
  when WcoEmail::EmailFilterAction::KIND_ADD_TAG
94
95
  conv.tags.push aject
@@ -111,11 +111,6 @@ class WcoEmail::MessageStub
111
111
  @message.save_attachment_postal( att )
112
112
  end
113
113
 
114
- ## _TODO
115
- # the_mail.cc&.each do |cc|
116
- # Wco::Lead.find_or_create_by_email( cc )
117
- # end
118
-
119
114
  @conv.update_attributes({
120
115
  status: WcoEmail::Conversation::STATUS_UNREAD,
121
116
  latest_at: json['date'].to_time.to_s || Time.now.to_datetime,
@@ -135,7 +130,7 @@ class WcoEmail::MessageStub
135
130
  reason = nil
136
131
 
137
132
  filter.conditions.each do |cond|
138
- reason ||= cond.apply(leadset: @leadset, message: @message )
133
+ reason ||= cond.apply(lead: @lead, leadset: @leadset, message: @message )
139
134
  end
140
135
 
141
136
  if reason
@@ -145,13 +140,14 @@ class WcoEmail::MessageStub
145
140
  skip_reason = nil
146
141
 
147
142
  filter.skip_conditions.each do |scond|
148
- skip_reason ||= scond.apply(leadset: @leadset, message: @message )
143
+ skip_reason ||= scond.apply(lead: @lead, leadset: @leadset, message: @message )
149
144
  end
150
145
 
151
146
  if skip_reason
152
147
  puts! "NOT Applying2 filter #{filter} to conv #{@message.conversation} for matching #{skip_reason}" if DEBUG
153
148
  else
154
- @conv.filters << filter; @conv.save
149
+ @conv.filters << filter
150
+ @conv.save
155
151
  filter.actions.each do |action|
156
152
  @message.apply_filter_action( action )
157
153
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wco_models
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0.304
4
+ version: 3.1.0.305
5
5
  platform: ruby
6
6
  authors:
7
7
  - Victor Pudeyev