postman_mta 0.1.8 → 0.2.3

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
- SHA1:
3
- metadata.gz: d341fea3804eb42f26906de6779b5fd1daa20b22
4
- data.tar.gz: 3be0bfdacfdfdbe6f0570ae02b4ac0b80673c668
2
+ SHA256:
3
+ metadata.gz: bc04ac2c8ab40ed842b78143e7cac798f1876defb5e9aa8bbe7f67cc9ab32144
4
+ data.tar.gz: 8f5f477cc5b86bdf800702f2d13545a9d250cac8e3fdcb23257bb33123a17cbf
5
5
  SHA512:
6
- metadata.gz: 401514dd9720e6b711f260f02bee6b69b3e75e61a440cd3fb0968d627b8797a7d33825db5b284e5c57a9a0ccf040053bd190e71e75ae0476f37f01617060b17c
7
- data.tar.gz: b7dcf70b5fd288601a7a2b28078e2a695d3f3f6ed9536d824624d6040ae795e47f696af51a6988231e10bcb2ed4881030c0c6acc0314302e059b9375bf965051
6
+ metadata.gz: af548b6ed0b23aa31817c3dddd8b6c5eea15c863e75c8c45bdb2a8ff005b6966f794466754e691db2ed43eef5f6a0455c5954664f2e18879cc1c39ff927e86ef
7
+ data.tar.gz: 975fe8c004c5e843f2a38b4ddf10e64ee39af9fa61fbfc6ed0d618a8b277dbacd68535f9fc8037aec0e59939c447a2427ec3cbd643a499bca6a57c094e34c5f3
@@ -1,7 +1,7 @@
1
1
  AllCops:
2
- TargetRubyVersion: 2.3
3
-
4
- Excludes:
2
+ NewCops: disable
3
+ TargetRubyVersion: 2.4
4
+ Exclude:
5
5
  - "Guardfile"
6
6
  - "Rakefile"
7
7
  - "bin/**/*"
@@ -30,7 +30,7 @@ Lint/AmbiguousBlockAssociation:
30
30
 
31
31
  ##################### Metrics ##################################
32
32
 
33
- Metrics/LineLength:
33
+ Layout/LineLength:
34
34
  Max: 110
35
35
 
36
36
  Metrics/ClassLength:
@@ -45,11 +45,3 @@ Metrics/BlockLength:
45
45
  Max: 50
46
46
  Exclude:
47
47
  - "**/*_spec.rb"
48
-
49
- ##################### Rails ##################################
50
-
51
- Rails:
52
- Enabled: true
53
-
54
- Rails/SkipsModelValidations:
55
- Enabled: false
@@ -0,0 +1 @@
1
+ 2.5.1
data/Gemfile CHANGED
@@ -9,6 +9,6 @@ group :development, :test do
9
9
  gem 'api_matchers', '~> 0.6.2'
10
10
  gem 'rails', '~> 5.0'
11
11
  gem 'rspec-rails', '~> 3.5', '>= 3.5.2'
12
- gem 'sqlite3', '~> 1.3', '>= 1.3.13'
12
+ gem 'sqlite3', '~> 1.3', '< 1.4'
13
13
  gem 'webmock', '~> 3.0', '>= 3.0.1'
14
14
  end
@@ -0,0 +1,27 @@
1
+ module PostmanMta
2
+ module Archive
3
+ class ConversationsController < ApplicationController
4
+ def index
5
+ render conversation.index(permitted_params)
6
+ end
7
+
8
+ def show
9
+ render conversation.find(params[:id])
10
+ end
11
+
12
+ def move
13
+ render conversation.move(permitted_params)
14
+ end
15
+
16
+ private
17
+
18
+ def conversation
19
+ @conversation ||= PostmanMta::Archive::Conversation.new
20
+ end
21
+
22
+ def permitted_params
23
+ params.permit!
24
+ end
25
+ end
26
+ end
27
+ end
@@ -5,9 +5,12 @@ module PostmanMta
5
5
  def show
6
6
  response = attachment.find(params[:uuid]).deep_symbolize_keys
7
7
  file = response.dig(:json, :attachment)
8
- file_data = Base64.decode64(file[:body])
9
8
 
10
- send_data(file_data, type: file[:content_type], filename: file[:filename], dispostion: 'attachment')
9
+ if file[:body].present?
10
+ send_attachment(file)
11
+ else
12
+ proxy_attachment(file)
13
+ end
11
14
  end
12
15
 
13
16
  private
@@ -15,5 +18,15 @@ module PostmanMta
15
18
  def attachment
16
19
  @attachment ||= PostmanMta::Attachment.new(params[:message_token])
17
20
  end
21
+
22
+ def send_attachment(file)
23
+ file_data = Base64.decode64(file[:body])
24
+ send_data(file_data, type: file[:content_type], filename: file[:filename], dispostion: 'attachment')
25
+ end
26
+
27
+ def proxy_attachment(file)
28
+ headers['X-Accel-Redirect'] = PostmanMta::Utils::SendfileUrl.new(file[:url]).to_url
29
+ headers['Content-Disposition'] = "attachment; filename=\"#{file[:filename]}\""
30
+ end
18
31
  end
19
32
  end
@@ -1,9 +1,17 @@
1
1
  module PostmanMta
2
2
  class LabelsController < ApplicationController
3
+ def index
4
+ render label.index(label_params)
5
+ end
6
+
3
7
  def create
4
8
  render label.create(label_params)
5
9
  end
6
10
 
11
+ def update
12
+ render label.update(params[:id], label_params)
13
+ end
14
+
7
15
  def destroy
8
16
  render label.destroy(params[:id])
9
17
  end
@@ -0,0 +1,17 @@
1
+ module PostmanMta
2
+ module Archive
3
+ class Conversation < PostmanMta::Conversation
4
+ def index(params = {})
5
+ get('/archive/conversations', body: params)
6
+ end
7
+
8
+ def find(conversation_id)
9
+ get("/archive/conversations/#{conversation_id}")
10
+ end
11
+
12
+ def move(params = {})
13
+ patch('/archive/conversations/move', body: params)
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,18 @@
1
+ module PostmanMta
2
+ class Bookmark < ApplicationModel
3
+ attr_reader :target_type, :target_id
4
+
5
+ def initialize(target_type, target_id)
6
+ @target_type = target_type
7
+ @target_id = target_id
8
+ end
9
+
10
+ def create(params)
11
+ post("/#{target_type}/#{target_id}/bookmarks", body: params)
12
+ end
13
+
14
+ def destroy(bookmark_id)
15
+ delete("/#{target_type}/#{target_id}/bookmarks/#{bookmark_id}")
16
+ end
17
+ end
18
+ end
@@ -4,10 +4,14 @@ module PostmanMta
4
4
  get('/conversations', body: params)
5
5
  end
6
6
 
7
+ def archive(params = {})
8
+ get('/archive/conversations', body: params)
9
+ end
10
+
7
11
  def folder(folder, params = {})
8
12
  params = {
9
13
  folder: folder
10
- }.merge(params)
14
+ }.merge!(params)
11
15
 
12
16
  get('/conversations', body: params)
13
17
  end
@@ -6,10 +6,18 @@ module PostmanMta
6
6
  @conversation_id = conversation_id
7
7
  end
8
8
 
9
+ def index(params = {})
10
+ get('/labels', body: params)
11
+ end
12
+
9
13
  def create(params)
10
14
  post("/conversations/#{conversation_id}/labels", body: params)
11
15
  end
12
16
 
17
+ def update(label_id, params)
18
+ patch("/conversations/#{conversation_id}/labels/#{label_id}", body: params)
19
+ end
20
+
13
21
  def destroy(label_id)
14
22
  delete("/conversations/#{conversation_id}/labels/#{label_id}")
15
23
  end
@@ -11,5 +11,9 @@ module PostmanMta
11
11
  def unread_stats
12
12
  get('/stats/messages/unread')
13
13
  end
14
+
15
+ def search(params = {})
16
+ get('/search/messages', body: params)
17
+ end
14
18
  end
15
19
  end
@@ -12,3 +12,7 @@ UtilityFunction:
12
12
  exclude:
13
13
  - "PostmanMta::Utils::Signature#digest"
14
14
  - "PostmanMta::ApiClient#perform_request"
15
+
16
+ FeatureEnvy:
17
+ exclude:
18
+ - 'PostmanMta::AttachmentsController#send_attachment'
@@ -14,7 +14,7 @@ PostmanMta::Engine.routes.draw do
14
14
  match :unread, on: :collection, via: [:put, :patch]
15
15
  match :move, on: :collection, via: [:put, :patch]
16
16
 
17
- resources :labels, only: [:create, :destroy]
17
+ resources :labels, only: [:create, :update, :destroy]
18
18
  resources :tags, only: [:create, :destroy]
19
19
  end
20
20
 
@@ -24,6 +24,13 @@ PostmanMta::Engine.routes.draw do
24
24
  end
25
25
  end
26
26
 
27
+ namespace :archive do
28
+ resources :conversations, only: [:index, :show] do
29
+ match :move, on: :collection, via: [:put, :patch]
30
+ end
31
+ end
32
+
27
33
  resources :routes, only: :index
28
34
  resources :domains, only: :index
35
+ resources :labels, only: :index
29
36
  end
@@ -5,6 +5,7 @@ module PostmanMta
5
5
  module Utils
6
6
  autoload :Signature, 'postman_mta/utils/signature'
7
7
  autoload :SignedRequest, 'postman_mta/utils/signed_request'
8
+ autoload :SendfileUrl, 'postman_mta/utils/sendfile_url'
8
9
  end
9
10
 
10
11
  autoload :ApiClient, 'postman_mta/api_client'
@@ -0,0 +1,21 @@
1
+ require 'uri'
2
+
3
+ module PostmanMta
4
+ module Utils
5
+ class SendfileUrl
6
+ PREFIX = '/private'.freeze
7
+
8
+ def initialize(data)
9
+ @data = data
10
+ end
11
+
12
+ def uri
13
+ @uri ||= URI(@data)
14
+ end
15
+
16
+ def to_url
17
+ File.join(PREFIX, uri.host, "#{uri.path}?#{uri.query}")
18
+ end
19
+ end
20
+ end
21
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PostmanMta
4
- VERSION = '0.1.8'
4
+ VERSION = '0.2.3'
5
5
  end
@@ -1,6 +1,6 @@
1
- # coding: utf-8
1
+ # frozen_string_literal: true
2
2
 
3
- lib = File.expand_path('../lib', __FILE__)
3
+ lib = File.expand_path('lib', __dir__)
4
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
  require 'postman_mta/version'
6
6
 
@@ -25,9 +25,11 @@ Gem::Specification.new do |spec|
25
25
 
26
26
  spec.add_development_dependency 'bundler', '~> 1.14'
27
27
  spec.add_development_dependency 'guard-rspec', '~> 4.7', '>= 4.7.3'
28
+ spec.add_development_dependency 'overcommit'
28
29
  spec.add_development_dependency 'rake', '~> 10.0'
29
30
  spec.add_development_dependency 'reek'
30
- spec.add_development_dependency 'overcommit'
31
+ spec.add_development_dependency 'rubocop'
32
+ spec.add_development_dependency 'sqlite3'
31
33
 
32
- spec.add_dependency 'httparty', '~> 0.15.6'
34
+ spec.add_dependency 'httparty', '~> 0.15'
33
35
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: postman_mta
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor Malinovskiy
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-02-26 00:00:00.000000000 Z
11
+ date: 2020-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -44,6 +44,20 @@ dependencies:
44
44
  - - ">="
45
45
  - !ruby/object:Gem::Version
46
46
  version: 4.7.3
47
+ - !ruby/object:Gem::Dependency
48
+ name: overcommit
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
47
61
  - !ruby/object:Gem::Dependency
48
62
  name: rake
49
63
  requirement: !ruby/object:Gem::Requirement
@@ -73,7 +87,21 @@ dependencies:
73
87
  - !ruby/object:Gem::Version
74
88
  version: '0'
75
89
  - !ruby/object:Gem::Dependency
76
- name: overcommit
90
+ name: rubocop
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ - !ruby/object:Gem::Dependency
104
+ name: sqlite3
77
105
  requirement: !ruby/object:Gem::Requirement
78
106
  requirements:
79
107
  - - ">="
@@ -92,14 +120,14 @@ dependencies:
92
120
  requirements:
93
121
  - - "~>"
94
122
  - !ruby/object:Gem::Version
95
- version: 0.15.6
123
+ version: '0.15'
96
124
  type: :runtime
97
125
  prerelease: false
98
126
  version_requirements: !ruby/object:Gem::Requirement
99
127
  requirements:
100
128
  - - "~>"
101
129
  - !ruby/object:Gem::Version
102
- version: 0.15.6
130
+ version: '0.15'
103
131
  description: This gem will add some routes to the application to forward requests
104
132
  from frontend to postman API
105
133
  email:
@@ -112,6 +140,7 @@ files:
112
140
  - ".overcommit.yml"
113
141
  - ".rspec"
114
142
  - ".rubocop.yml"
143
+ - ".ruby-version"
115
144
  - ".travis.yml"
116
145
  - Gemfile
117
146
  - Guardfile
@@ -119,6 +148,7 @@ files:
119
148
  - README.md
120
149
  - Rakefile
121
150
  - app/controllers/postman_mta/application_controller.rb
151
+ - app/controllers/postman_mta/archive/conversations_controller.rb
122
152
  - app/controllers/postman_mta/attachments_controller.rb
123
153
  - app/controllers/postman_mta/conversations_controller.rb
124
154
  - app/controllers/postman_mta/domains_controller.rb
@@ -128,7 +158,9 @@ files:
128
158
  - app/controllers/postman_mta/stats/messages_controller.rb
129
159
  - app/controllers/postman_mta/tags_controller.rb
130
160
  - app/models/postman_mta/application_model.rb
161
+ - app/models/postman_mta/archive/conversation.rb
131
162
  - app/models/postman_mta/attachment.rb
163
+ - app/models/postman_mta/bookmark.rb
132
164
  - app/models/postman_mta/conversation.rb
133
165
  - app/models/postman_mta/credential.rb
134
166
  - app/models/postman_mta/domain.rb
@@ -144,6 +176,7 @@ files:
144
176
  - lib/postman_mta/api_client.rb
145
177
  - lib/postman_mta/api_request.rb
146
178
  - lib/postman_mta/engine.rb
179
+ - lib/postman_mta/utils/sendfile_url.rb
147
180
  - lib/postman_mta/utils/signature.rb
148
181
  - lib/postman_mta/utils/signed_request.rb
149
182
  - lib/postman_mta/version.rb
@@ -168,7 +201,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
168
201
  version: '0'
169
202
  requirements: []
170
203
  rubyforge_project:
171
- rubygems_version: 2.5.2
204
+ rubygems_version: 2.7.6
172
205
  signing_key:
173
206
  specification_version: 4
174
207
  summary: Rails gem to easy integrate postman to your application