ish_models 0.0.33.210 → 0.0.33.211

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/office/email_message.rb +21 -8
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 46e7967e2f0d884e8c5ff8a5a6e6d54aed2cc64b605a286ed40f3e2b9417fcdd
4
- data.tar.gz: bd0fb0ca21faef2ed8f2d42068756087fa80b5199fd887552a2989411b187145
3
+ metadata.gz: 846b485fb78f382c7d084c59e34ed913434821c725a22fd83ebc1cf13e65e7c0
4
+ data.tar.gz: 5f2a09a0a4671ffe36d0986ecc061de33c1a45188c8c9394fc73a04d3ae00b04
5
5
  SHA512:
6
- metadata.gz: ab02dca3ecf3add944f5f35bb1ed4977996acd81dd7fc33570307a7826d120a2fce295785d8d4fde754c3e516f1b73d0dcb9cdee28b40698188a5ee771211e4a
7
- data.tar.gz: d41c6bb9bd15965fec727922217d2095b386770f9f6511bb6de0c1610fe156194da3656e6245574a258a0cc02c7c5db9a4312da2fc6cd96b6f38fba57c23bf3b
6
+ metadata.gz: 86344c408514561160296d4b4fc6a3647da3f85028fc3ac41cb9c03d7a7271ea2a4984c8875a9dda412d1306be1d6ffb5a960ce5f2e5a35e7b3259444c4704e6
7
+ data.tar.gz: aff1681e76aa26eb7d322ebe8988da180b6b20fa42c68c40b235b1ed45957b762f95a31969dfc3b00985c93eff267833415b75a92f06c849442aa7118bc44929
@@ -41,23 +41,34 @@ class Office::EmailMessage
41
41
 
42
42
  ## Copied to email_conversation
43
43
  field :wp_term_ids, type: Array, default: []
44
+
44
45
  ## Tested manually ok, does not pass the spec. @TODO: hire to make pass spec? _vp_ 2023-03-07
45
46
  def add_tag tag
46
- if WpTag == tag.class
47
- self[:wp_term_ids] = self[:wp_term_ids].push(tag.id).uniq
48
- self.save!
47
+ case tag.class.name
48
+ when 'WpTag'
49
+ ;
50
+ when 'String'
51
+ tag = WpTag.emailtag(tag)
49
52
  else
50
- throw "#add_tag expects a WpTag as the only parameter."
53
+ throw "#add_tag2 expects a WpTag or string (eg WpTag::INBOX) as the only parameter."
51
54
  end
55
+ self[:wp_term_ids] = ( [ tag.id ] + self[:wp_term_ids] ).uniq
56
+ self.save!
52
57
  end
53
58
  def remove_tag tag
54
- if WpTag == tag.class
55
- self[:wp_term_ids].delete( tag.id )
56
- self.save!
59
+ case tag.class.name
60
+ when 'WpTag'
61
+ ;
62
+ when 'String'
63
+ tag = WpTag.emailtag(tag)
57
64
  else
58
- throw "#remove_tag expects a WpTag as the only parameter."
65
+ throw "#remove_tag2 expects a WpTag or string (eg WpTag::INBOX) as the only parameter."
59
66
  end
67
+ self[:wp_term_ids] = self[:wp_term_ids] - [ tag.id ]
68
+ out = self.save!
69
+ out
60
70
  end
71
+ def rmtag tag; remove_tag tag; end
61
72
 
62
73
  belongs_to :email_conversation
63
74
  def conv
@@ -74,10 +85,12 @@ class Office::EmailMessage
74
85
  from[0].split('@')[1]
75
86
  end
76
87
 
88
+ ## @TODO: move to email_conversation _vp_ 2023-03-24
77
89
  def apply_filter filter
78
90
  case filter.kind
79
91
  when ::Office::EmailFilter::KIND_SKIP_INBOX
80
92
  self.remove_tag( WpTag::INBOX )
93
+ self.conv.remove_tag( WpTag::INBOX )
81
94
  when ::Office::EmailFilter::KIND_AUTORESPOND
82
95
  Ish::EmailContext.create({
83
96
  email_template: ::Tmpl.find_by_slug( filter.email_template_slug ),
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.210
4
+ version: 0.0.33.211
5
5
  platform: ruby
6
6
  authors:
7
7
  - piousbox