postman_mta 0.1.9 → 0.2.4
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 +5 -5
- data/.rubocop.yml +4 -12
- data/.ruby-version +1 -0
- data/Gemfile +1 -1
- data/app/controllers/postman_mta/archive/conversations_controller.rb +27 -0
- data/app/controllers/postman_mta/attachments_controller.rb +16 -2
- data/app/controllers/postman_mta/labels_controller.rb +8 -0
- data/app/models/postman_mta/archive/conversation.rb +17 -0
- data/app/models/postman_mta/conversation.rb +5 -1
- data/app/models/postman_mta/label.rb +8 -0
- data/config.reek +4 -0
- data/config/routes.rb +8 -1
- data/lib/postman_mta.rb +2 -0
- data/lib/postman_mta/record_not_found.rb +3 -0
- data/lib/postman_mta/utils/sendfile_url.rb +21 -0
- data/lib/postman_mta/version.rb +1 -1
- data/postman_mta.gemspec +1 -0
- metadata +22 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 63d6c39090e609521da139680163a8ea087177b08058fa9c891200ed74b2db24
|
4
|
+
data.tar.gz: aad564e61a4c45ff2bbcfae4f1415acee51a0c5e064431974977a10fd2af4741
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f4c30c98c0a6baa305f4676965941e404b60421decf6ea2c71f5f934bf0c4bc597296955da11aa05caf67abc2315bdd4c95b8f9e7c2308be443d470ee3e7c6ec
|
7
|
+
data.tar.gz: c03703cc5f1d59d2b0bde4aa848fdb7ea95366a9cdb9bc3049ff00c704bd2115d9893ae15641ea2e4d29178dfece718dcce1045ba6050b6820941470dce02caf
|
data/.rubocop.yml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
AllCops:
|
2
|
-
|
3
|
-
|
4
|
-
|
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
|
-
|
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
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.5.1
|
data/Gemfile
CHANGED
@@ -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,13 @@ module PostmanMta
|
|
5
5
|
def show
|
6
6
|
response = attachment.find(params[:uuid]).deep_symbolize_keys
|
7
7
|
file = response.dig(:json, :attachment)
|
8
|
-
|
8
|
+
raise(PostmanMta::RecordNotFound, "Attachment via id #{params[:uuid]} not found") unless file
|
9
9
|
|
10
|
-
|
10
|
+
if file[:body].present?
|
11
|
+
send_attachment(file)
|
12
|
+
else
|
13
|
+
proxy_attachment(file)
|
14
|
+
end
|
11
15
|
end
|
12
16
|
|
13
17
|
private
|
@@ -15,5 +19,15 @@ module PostmanMta
|
|
15
19
|
def attachment
|
16
20
|
@attachment ||= PostmanMta::Attachment.new(params[:message_token])
|
17
21
|
end
|
22
|
+
|
23
|
+
def send_attachment(file)
|
24
|
+
file_data = Base64.decode64(file[:body])
|
25
|
+
send_data(file_data, type: file[:content_type], filename: file[:filename], dispostion: 'attachment')
|
26
|
+
end
|
27
|
+
|
28
|
+
def proxy_attachment(file)
|
29
|
+
headers['X-Accel-Redirect'] = PostmanMta::Utils::SendfileUrl.new(file[:url]).to_url
|
30
|
+
headers['Content-Disposition'] = "attachment; filename=\"#{file[:filename]}\""
|
31
|
+
end
|
18
32
|
end
|
19
33
|
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
|
@@ -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
|
data/config.reek
CHANGED
data/config/routes.rb
CHANGED
@@ -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
|
data/lib/postman_mta.rb
CHANGED
@@ -5,10 +5,12 @@ 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'
|
11
12
|
autoload :ApiRequest, 'postman_mta/api_request'
|
13
|
+
autoload :RecordNotFound, 'postman_mta/record_not_found'
|
12
14
|
|
13
15
|
mattr_accessor :api_key
|
14
16
|
mattr_accessor :api_secret
|
@@ -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
|
data/lib/postman_mta/version.rb
CHANGED
data/postman_mta.gemspec
CHANGED
@@ -29,6 +29,7 @@ Gem::Specification.new do |spec|
|
|
29
29
|
spec.add_development_dependency 'rake', '~> 10.0'
|
30
30
|
spec.add_development_dependency 'reek'
|
31
31
|
spec.add_development_dependency 'rubocop'
|
32
|
+
spec.add_development_dependency 'sqlite3'
|
32
33
|
|
33
34
|
spec.add_dependency 'httparty', '~> 0.15'
|
34
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.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor Malinovskiy
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-12-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -100,6 +100,20 @@ dependencies:
|
|
100
100
|
- - ">="
|
101
101
|
- !ruby/object:Gem::Version
|
102
102
|
version: '0'
|
103
|
+
- !ruby/object:Gem::Dependency
|
104
|
+
name: sqlite3
|
105
|
+
requirement: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
type: :development
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
103
117
|
- !ruby/object:Gem::Dependency
|
104
118
|
name: httparty
|
105
119
|
requirement: !ruby/object:Gem::Requirement
|
@@ -126,6 +140,7 @@ files:
|
|
126
140
|
- ".overcommit.yml"
|
127
141
|
- ".rspec"
|
128
142
|
- ".rubocop.yml"
|
143
|
+
- ".ruby-version"
|
129
144
|
- ".travis.yml"
|
130
145
|
- Gemfile
|
131
146
|
- Guardfile
|
@@ -133,6 +148,7 @@ files:
|
|
133
148
|
- README.md
|
134
149
|
- Rakefile
|
135
150
|
- app/controllers/postman_mta/application_controller.rb
|
151
|
+
- app/controllers/postman_mta/archive/conversations_controller.rb
|
136
152
|
- app/controllers/postman_mta/attachments_controller.rb
|
137
153
|
- app/controllers/postman_mta/conversations_controller.rb
|
138
154
|
- app/controllers/postman_mta/domains_controller.rb
|
@@ -142,6 +158,7 @@ files:
|
|
142
158
|
- app/controllers/postman_mta/stats/messages_controller.rb
|
143
159
|
- app/controllers/postman_mta/tags_controller.rb
|
144
160
|
- app/models/postman_mta/application_model.rb
|
161
|
+
- app/models/postman_mta/archive/conversation.rb
|
145
162
|
- app/models/postman_mta/attachment.rb
|
146
163
|
- app/models/postman_mta/bookmark.rb
|
147
164
|
- app/models/postman_mta/conversation.rb
|
@@ -159,6 +176,8 @@ files:
|
|
159
176
|
- lib/postman_mta/api_client.rb
|
160
177
|
- lib/postman_mta/api_request.rb
|
161
178
|
- lib/postman_mta/engine.rb
|
179
|
+
- lib/postman_mta/record_not_found.rb
|
180
|
+
- lib/postman_mta/utils/sendfile_url.rb
|
162
181
|
- lib/postman_mta/utils/signature.rb
|
163
182
|
- lib/postman_mta/utils/signed_request.rb
|
164
183
|
- lib/postman_mta/version.rb
|
@@ -183,7 +202,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
183
202
|
version: '0'
|
184
203
|
requirements: []
|
185
204
|
rubyforge_project:
|
186
|
-
rubygems_version: 2.6
|
205
|
+
rubygems_version: 2.7.6
|
187
206
|
signing_key:
|
188
207
|
specification_version: 4
|
189
208
|
summary: Rails gem to easy integrate postman to your application
|