ish_models 0.0.33.199 → 0.0.33.201

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: be6a67454f480e9326367814538e156463b46ebfe974dea533ba34a39195b0c7
4
- data.tar.gz: 884761d610983c25d8346a3d1f51ce8e8b4026a70ffeec8a907acf5142ea6283
3
+ metadata.gz: 5f7b84c12b393ec05bb90bf8b5f0cbebf9f56b4a03cc7109024721da40267834
4
+ data.tar.gz: 9e9f21da6318f174be8e1ad53d6d04ae39554bc7b0fcb4f158930deda6387e77
5
5
  SHA512:
6
- metadata.gz: eaa67007ba2789c286437cd07e04bc3db129e57025599cdebe21fd468f29a1e7c0756ab894f62c8b1ea7aaf193ddcf27a0a424c04d75f070348c13702323783f
7
- data.tar.gz: eec156543395ad6f723b4ef73f06264b183f17d17daf523bd4d684148da9bf652739c12cd3140d0fababf2cc6df49643135e0e9887bfa498bdfafef0ace38bdc
6
+ metadata.gz: 87be8ad0b221c7ead2a100b14e752bc67c32a6fe7b941d1153f92aa857050e3ebd3e775d74a8708ebec523585f791797d19f9a5fe0f479cad2df810fd025810a
7
+ data.tar.gz: 063d5e1a5d5fe71c7c3545768869d01c9c1461aa4bc14c2b958526c5be8232ae013a37ae8952b716d5f3c5ac6c7a36de8fc938df7e51d17f23ca16ac61b7923f
@@ -17,18 +17,20 @@ class Office::EmailConversation
17
17
  Lead.find( lead_ids )
18
18
  end
19
19
 
20
- field :term_ids, type: :array, default: []
21
- def tags
22
- WpTag.find( term_ids )
23
- end
20
+
24
21
 
25
22
  has_many :email_messages
26
23
  def email_messages
27
24
  Office::EmailMessage.where( email_conversation_id: self.id )
28
25
  end
29
26
 
27
+ def tags
28
+ WpTag.find( wp_term_ids )
29
+ end
30
+
30
31
  ## Copied from email_message
31
32
  field :wp_term_ids, type: Array, default: []
33
+
32
34
  ## Tested manually ok, does not pass the spec. @TODO: hire to make pass spec? _vp_ 2023-03-07
33
35
  def add_tag tag
34
36
  if WpTag == tag.class
@@ -38,6 +40,7 @@ class Office::EmailConversation
38
40
  throw "#add_tag expects a WpTag as the only parameter."
39
41
  end
40
42
  end
43
+
41
44
  def remove_tag tag
42
45
  if WpTag == tag.class
43
46
  self[:wp_term_ids].delete( tag.id )
@@ -47,6 +50,22 @@ class Office::EmailConversation
47
50
  end
48
51
  end
49
52
 
53
+ def self.in_inbox
54
+ ::Office::EmailConversation.where( :wp_term_ids => WpTag.email_inbox_tag.id ).order_by( latest_at: :desc )
55
+ end
56
+
57
+ def self.in_emailtag which
58
+ case which.class.name
59
+ when 'String'
60
+ tag_id = WpTag.emailtag(which).id
61
+ when 'WpTag'
62
+ tag_id = which.id
63
+ else
64
+ throw "unsupported in #in_emailtag: #{which}"
65
+ end
66
+ return ::Office::EmailConversation.where( :wp_term_ids => tag_id ).order_by( latest_at: :desc )
67
+ end
68
+
50
69
  end
51
70
  # EmailConversation = Office::EmailConversation
52
71
  Conv = Office::EmailConversation
@@ -101,26 +101,3 @@ class Office::EmailMessage
101
101
 
102
102
  end
103
103
  ::Msg = Office::EmailMessage
104
-
105
-
106
-
107
- ## trash _vp_ 2023-03-07
108
- # def process
109
- # Aws.config[:credentials] = Aws::Credentials.new(
110
- # ::S3_CREDENTIALS[:access_key_id],
111
- # ::S3_CREDENTIALS[:secret_access_key]
112
- # )
113
- # s3 = Aws::S3::Client.new
114
- # obj = s3.get_object({
115
- # bucket: 'ish-ses',
116
- # key: self.object_key
117
- # })
118
- # obj2 = obj.body.read
119
- # mail = Mail.read_from_string( obj2 )
120
- # self.from = mail.from
121
- # self.to = mail.to
122
- # self.subject = mail.subject
123
- # self.date = mail.date
124
- # self.raw = obj2
125
- # self.save
126
- # end
@@ -17,7 +17,7 @@ class Office::EmailMessageStub
17
17
  field :object_path, type: :string ## A routable s3 url ## @TODO: remove this field. _vp_ 2023-03-07
18
18
  # validates_presence_of :object_path ## only need object_key == message_id
19
19
 
20
- field :term_ids, type: :array, default: []
20
+ field :wp_term_ids, type: :array, default: []
21
21
 
22
22
  end
23
23
  Stub = EMS = Office::EmailMessageStub
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.199
4
+ version: 0.0.33.201
5
5
  platform: ruby
6
6
  authors:
7
7
  - piousbox