ish_models 0.0.33.246 → 0.0.33.248

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c4d9c4a1432222dac50b23ec2b44f805fd7d67bd2c1797218abb86280303343d
4
- data.tar.gz: 6cda8b0de6f72e2cfe61579e2590f7d5636daddf68d87e36c6cbc35b5492fe56
3
+ metadata.gz: 2def700aeaad8af0e705ff8942ad3644d42e9bd1ac93360dda132e81eac94c3a
4
+ data.tar.gz: 0efc6da855db6c6087405a8a86a32c1c5ec331fa6605f5c73bf6ba50cd3ab788
5
5
  SHA512:
6
- metadata.gz: c11c49f0d877be6f3730a80f467c4de7afb7de52be03679128c0c9d0ee44e62dd4af36b15fd7ee72581aabcaa7ef40ea537ae676ba0612a58430d75232baffe3
7
- data.tar.gz: 329d36a6aa69828ef8b129d24a18e8bd1742977ba340e5909b00af634066e9717ea84aed13107b3c5bac5a278f791f4f6252dc42c5a21a60eebca65f24f8dc45
6
+ metadata.gz: 980d5d0b40716c183f460e92dceb012e0999a04f6449b9b5a637d45c1109f504949d6fd45cb598ef3263fb96f90dfac4609c9bfe10e280a2f1af1dbcae526515
7
+ data.tar.gz: e2629dfb10d8554ac7da8f8c5541f38da1f02333e5259ac0f2bedd7fd2d68d3b5ad5e7ca1532b31ca769f918a253f97d8feeed1fcca66fe78766c77e0f5ad7f0
@@ -45,8 +45,9 @@ class ::Ish::EmailTemplate
45
45
  binding()
46
46
  end
47
47
 
48
- has_many :email_actions, class_name: '::Office::EmailAction'
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
@@ -41,19 +41,20 @@ class Ish::UserProfile
41
41
  ROLE_ADMIN = :admin
42
42
  field :role_name, :type => Symbol, default: :guy
43
43
 
44
- has_one :profile_photo, inverse_of: :profile_city, class_name: 'Photo'
44
+ has_one :profile_photo, inverse_of: :profile_city, class_name: 'Photo'
45
45
  has_many :galleries, inverse_of: :user_profile
46
46
  has_and_belongs_to_many :shared_galleries, inverse_of: :shared_profiles, class_name: 'Gallery'
47
47
  has_and_belongs_to_many :shared_markers, inverse_of: :shared_profiles, class_name: 'Gameui::Marker'
48
48
  has_and_belongs_to_many :shared_locations, inverse_of: :shared_profiles, class_name: 'Gameui::Map'
49
+ has_and_belongs_to_many :shared_reports, inverse_of: :shared_profiles, class_name: '::Report'
49
50
  has_and_belongs_to_many :shared_videos, inverse_of: :shared_profiles, class_name: '::Video'
50
51
  has_many :my_markers, inverse_of: :creator_profile, class_name: 'Gameui::Marker'
51
52
  has_many :my_locations, inverse_of: :creator_profile, class_name: 'Gameui::Map'
52
53
  has_many :invoices, class_name: '::Ish::Invoice'
53
54
  has_many :photos
54
55
  has_many :reports, inverse_of: :user_profile
55
- has_many :videos, inverse_of: :user_profile
56
- has_many :newsitems, inverse_of: :profile
56
+ has_many :videos, inverse_of: :user_profile
57
+ has_many :newsitems, inverse_of: :profile
57
58
 
58
59
  def sudoer?
59
60
  %w( piousbox@gmail.com victor@wasya.co ).include?( self.email )
@@ -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 'WpTag'
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!
@@ -7,19 +7,36 @@ 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
- KIND_SKIP_INBOX = 'skip-inbox'
14
- KIND_AUTORESPOND = 'autorespond'
15
- KINDS = [ nil, KIND_SKIP_INBOX, KIND_AUTORESPOND ]
16
+ KIND_AUTORESPOND = 'autorespond' # @deprecated, DO NOT USE!
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
+ KIND_DELETE = 'delete' # @obsolete, use add-tag
22
+ KIND_SKIP_INBOX = 'skip-inbox' # @obsolete, use remove-tag
23
+
24
+ KINDS = [ nil, KIND_AUTORESPOND_TMPL, KIND_AUTORESPOND_EACT, KIND_SKIP_INBOX, KIND_ADD_TAG, KIND_REMOVE_TAG]
16
25
  field :kind
17
26
 
18
- STATE_ACTIVE = 'active'
27
+ STATE_ACTIVE = 'active'
19
28
  STATE_INACTIVE = 'inactive'
20
29
  STATES = [ STATE_ACTIVE, STATE_INACTIVE ]
21
30
  field :state, type: :string, default: STATE_ACTIVE
22
31
  scope :active, ->{ where( state: STATE_ACTIVE ) }
23
32
 
33
+ belongs_to :email_template, class_name: 'Ish::EmailTemplate', optional: true
34
+ belongs_to :email_action, class_name: 'Office::EmailAction', optional: true
35
+
36
+ field :wp_term_id, type: :integer
37
+ def category
38
+ self.wp_term_id && WpTag.find( self.wp_term_id )
39
+ end
40
+
24
41
  end
25
42
 
@@ -93,14 +93,33 @@ 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
+ ## @deprecated, use KIND_REMOVE_TAG
96
98
  when ::Office::EmailFilter::KIND_SKIP_INBOX
97
99
  # self.remove_tag( WpTag::INBOX )
98
100
  self.conv.remove_tag( WpTag::INBOX )
99
- when ::Office::EmailFilter::KIND_AUTORESPOND
101
+
102
+ when ::Office::EmailFilter::KIND_ADD_TAG
103
+ self.conv.add_tag( filter.wp_term_id )
104
+
105
+ when ::Office::EmailFilter::KIND_REMOVE_TAG
106
+ self.conv.remove_tag( filter.wp_term_id )
107
+
108
+ when ::Office::EmailFilter::KIND_AUTORESPOND_TMPL
100
109
  Ish::EmailContext.create({
101
- email_template: ::Tmpl.find_by_slug( filter.email_template_slug ),
102
- lead: lead,
110
+ email_template: filter.email_template,
111
+ lead_id: lead.id,
112
+ send_at: Time.now + 22.minutes,
103
113
  })
114
+
115
+ when ::Office::EmailFilter::KIND_AUTORESPOND_EACT
116
+ ::Sch.create({
117
+ email_action: filter.email_action,
118
+ state: ::Sch::STATE_ACTIVE,
119
+ lead_id: lead.id,
120
+ perform_at: Time.now + 22.minutes,
121
+ })
122
+
104
123
  else
105
124
  raise "unknown filter kind: #{filter.kind}"
106
125
  end
data/lib/report.rb CHANGED
@@ -35,6 +35,7 @@ class Report
35
35
  field :z, :type => Float
36
36
 
37
37
  belongs_to :user_profile, :optional => true, :class_name => 'Ish::UserProfile'
38
+ has_and_belongs_to_many :shared_profiles, :class_name => 'Ish::UserProfile', :inverse_of => :shared_reports
38
39
 
39
40
  has_one :photo
40
41
 
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.246
4
+ version: 0.0.33.248
5
5
  platform: ruby
6
6
  authors:
7
7
  - piousbox