wco_email 0.1.1.81 → 0.1.1.82

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: cb4cda304553c3ccdc232709927e68ce17be6511d0bb26df1fa7880f8a4974b8
4
- data.tar.gz: 9de4dd2f1c693a4cfe1e814d6925cb496c6edc3e253561a61411ba0ed9bf3d69
3
+ metadata.gz: 25aa0ee19f524e32baf66b2d9c6a3d0d8309d4d3d152a2ce0b18ff312fc71507
4
+ data.tar.gz: 7cd5659cdf4fab3c45bf4afd6ebfa62b099874fe3edaefdf66baf8227e5aac05
5
5
  SHA512:
6
- metadata.gz: 20216f0274fbce9ffb1fcdc554db12b9034e9e3f0c74a83f6da2d1872504e9ab9c2f8de6077cbd997bb9230b94d0dee40f643cb281c1283ee045fb7eaa801279
7
- data.tar.gz: 283b1a319bec4a25a2642c3cbb73a60d0b383287cdfe41cf32974fa41b5d5a6a35cb02b4f4982fee7eeaa9e4e4f793773e9f36bbbfe2adb194d5e76ac8419a78
6
+ metadata.gz: 8e78e8dda9333d121c654eac15815c4da7d5187300a36a8753391bc2fad347fb067daa7bfa8e02d2d5adf6461e17e732f15fadb0085163143692794c8e2521c0
7
+ data.tar.gz: b9891c94d3cc5ec4fae1527d9dab6191301c7b203009ac25195ec429059a876b0ac6518caec9fdbc8937badcddd1ff6688047ca8cf652f9c9ff08f876ff3f57e
@@ -0,0 +1,10 @@
1
+
2
+ class WcoEmail::Api::ConversationsController < WcoEmail::ApiController
3
+
4
+ def index
5
+ authorize! :index, WcoEmail::Conversation
6
+ @conversations, @messages, @tag = WcoEmail::Conversation.load_conversations_messages_tag_by_params_and_profile( params, current_profile )
7
+ end
8
+
9
+ end
10
+
@@ -30,6 +30,10 @@ class WcoEmail::ApiController < ActionController::Base
30
30
  end
31
31
  end
32
32
 
33
+ def current_profile
34
+ Wco::Profile.find_by email: current_user.email
35
+ end
36
+
33
37
  def decode_jwt
34
38
  if Rails.env.test?
35
39
  sign_in User.find_by({ email: 'victor@wasya.co' })
@@ -29,44 +29,7 @@ class WcoEmail::ConversationsController < WcoEmail::ApplicationController
29
29
 
30
30
  def index
31
31
  authorize! :index, WcoEmail::Conversation
32
- @conversations = WcoEmail::Conversation.all
33
-
34
- if params[:tagname]
35
- @tag = Wco::Tag.find_by slug: params[:tagname]
36
- @conversations = @conversations.where( :tag_ids.in => [ @tag.id ] )
37
- end
38
- if params[:tagname_not]
39
- @tag_not = Wco::Tag.find_by slug: params[:tagname_not]
40
- @conversations = @conversations.where( :tag_ids.nin => [ @tag_not.id ] )
41
- end
42
-
43
- if params[:subject].present?
44
- @conversations = @conversations.where({ subject: /.*#{params[:subject]}.*/i })
45
- end
46
-
47
- if params[:from_email].present?
48
- @conversations = @conversations.where({ from_emails: /.*#{params[:from_email]}.*/i })
49
- end
50
-
51
- if params[:lead_id].present?
52
- @conversations = @conversations.where( lead_ids: params[:lead_id] )
53
- end
54
-
55
- @conversations = @conversations.where(
56
- ).includes( :leads, :messages, :tags
57
- ).order_by( latest_at: :desc
58
- ).page( params[:conv_page] ).per( current_profile.per_page )
59
-
60
- conversation_ids = @conversations.map &:id
61
-
62
- @messages_hash = {}
63
- messages = WcoEmail::Message.where(
64
- :conversation_id.in => conversation_ids,
65
- read_at: nil,
66
- )
67
- messages.map do |msg|
68
- @messages_hash[msg.id.to_s] = msg
69
- end
32
+ @conversations, @messages, @tag = WcoEmail::Conversation.load_conversations_messages_tag_by_params_and_profile( params, current_profile )
70
33
  end
71
34
 
72
35
  ## merge conv1 into conv2, and delete conv1
@@ -0,0 +1,4 @@
1
+
2
+ json.conversations @conversations
3
+ json.messages @messages
4
+ json.tag @tag
data/config/routes.rb CHANGED
@@ -7,6 +7,8 @@ WcoEmail::Engine.routes.draw do
7
7
  get 'tinymce', to: 'application#tinymce', as: :application_tinymce
8
8
 
9
9
  get 'api/contexts/summary', to: '/wco_email/api/contexts#summary'
10
+ get 'api/conversations', to: '/wco_email/api/conversations#index'
11
+ get 'api/tags/:tagname/conversations', to: '/wco_email/api/conversations#index'
10
12
 
11
13
  get 'conversations/in/:tagname', to: '/wco_email/conversations#index', as: :conversations_in
12
14
  get 'conversations/not-in/:tagname_not', to: '/wco_email/conversations#index', as: :conversations_not_in
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wco_email
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1.81
4
+ version: 0.1.1.82
5
5
  platform: ruby
6
6
  authors:
7
7
  - Victor Pudeyev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-08-29 00:00:00.000000000 Z
11
+ date: 2024-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-s3
@@ -310,6 +310,7 @@ files:
310
310
  - app/assets/stylesheets/wco_email/messages.scss
311
311
  - app/assets/stylesheets/wco_email/tags.scss
312
312
  - app/controllers/wco_email/api/contexts_controller.rb
313
+ - app/controllers/wco_email/api/conversations_controller.rb
313
314
  - app/controllers/wco_email/api_controller.rb
314
315
  - app/controllers/wco_email/application_controller.rb
315
316
  - app/controllers/wco_email/contexts_controller.rb
@@ -368,6 +369,7 @@ files:
368
369
  - app/views/wco_email/_main_header.haml
369
370
  - app/views/wco_email/_sidebar.haml
370
371
  - app/views/wco_email/api/contexts/summary.json.jbuilder
372
+ - app/views/wco_email/api/conversations/index.json.jbuilder
371
373
  - app/views/wco_email/contexts/_form.haml
372
374
  - app/views/wco_email/contexts/_form_reply.haml
373
375
  - app/views/wco_email/contexts/_header.haml