maestrano-connector-rails 1.2.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +41 -0
- data/.rubocop_todo.yml +180 -0
- data/.ruby-version +1 -1
- data/CODESHIP.md +3 -1
- data/Gemfile +16 -10
- data/Rakefile +12 -12
- data/VERSION +1 -1
- data/app/controllers/maestrano/account/group_users_controller.rb +5 -7
- data/app/controllers/maestrano/account/groups_controller.rb +5 -7
- data/app/controllers/maestrano/application_controller.rb +1 -1
- data/app/controllers/maestrano/auth/saml_controller.rb +5 -10
- data/app/controllers/maestrano/connec_controller.rb +12 -11
- data/app/controllers/maestrano/sessions_controller.rb +1 -1
- data/app/controllers/maestrano/synchronizations_controller.rb +7 -9
- data/app/controllers/version_controller.rb +9 -0
- data/app/helpers/maestrano/connector/rails/session_helper.rb +0 -2
- data/app/jobs/maestrano/connector/rails/all_synchronizations_job.rb +2 -2
- data/app/jobs/maestrano/connector/rails/push_to_connec_job.rb +8 -7
- data/app/jobs/maestrano/connector/rails/push_to_connec_worker.rb +6 -4
- data/app/jobs/maestrano/connector/rails/synchronization_job.rb +10 -9
- data/app/models/maestrano/connector/rails/complex_entity.rb +1 -1
- data/app/models/maestrano/connector/rails/concerns/complex_entity.rb +10 -12
- data/app/models/maestrano/connector/rails/concerns/connec_helper.rb +20 -25
- data/app/models/maestrano/connector/rails/concerns/connector_logger.rb +1 -1
- data/app/models/maestrano/connector/rails/concerns/entity.rb +63 -69
- data/app/models/maestrano/connector/rails/concerns/entity_base.rb +3 -3
- data/app/models/maestrano/connector/rails/concerns/external.rb +2 -2
- data/app/models/maestrano/connector/rails/concerns/sub_entity_base.rb +13 -15
- data/app/models/maestrano/connector/rails/connector_logger.rb +1 -1
- data/app/models/maestrano/connector/rails/entity.rb +1 -1
- data/app/models/maestrano/connector/rails/external.rb +1 -1
- data/app/models/maestrano/connector/rails/id_map.rb +1 -2
- data/app/models/maestrano/connector/rails/organization.rb +12 -14
- data/app/models/maestrano/connector/rails/sub_entity_base.rb +1 -1
- data/app/models/maestrano/connector/rails/synchronization.rb +17 -15
- data/app/models/maestrano/connector/rails/user.rb +1 -2
- data/app/models/maestrano/connector/rails/user_organization_rel.rb +1 -2
- data/config/routes.rb +4 -2
- data/lib/maestrano/connector/rails.rb +17 -2
- data/lib/maestrano_connector_rails.rb +1 -0
- data/maestrano-connector-rails.gemspec +32 -13
- data/release_notes.md +5 -0
- data/spec/controllers/version_controller_spec.rb +17 -0
- data/spec/dummy/config/application.rb +1 -1
- data/spec/jobs/push_to_connec_worker_spec.rb +16 -5
- data/spec/models/synchronization_spec.rb +9 -9
- data/spec/models/user_organization_rel_spec.rb +1 -1
- data/template/maestrano-connector-template.rb +2 -17
- metadata +90 -16
- data/lib/maestrano-connector-rails.rb +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 33ca5ce6a87c49a85d92343cd1ca3fc95aa40f5a
|
4
|
+
data.tar.gz: 3f152361f671a50af5c3b6de00f70e5e5b4ecdc3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b4e1d85bb3002e08842c4bcd0465e8580c733cda97b4174de3bb3608b49a6a677293d5b4473bf01abb694eb19c6e733d6b091ec76df2d1e3c782b9aaea671c7
|
7
|
+
data.tar.gz: e1ad34efc0df915117050afbb547e1dbbcb6a8b178081518749c9bd7675b39f32d3de969cd34bf2e323c0498eace1f6b6c1048bbdc40757ec54934b600109dad
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# require: rubocop-rspec
|
2
|
+
inherit_from: .rubocop_todo.yml
|
3
|
+
|
4
|
+
Rails:
|
5
|
+
Enabled: true
|
6
|
+
|
7
|
+
AllCops:
|
8
|
+
TargetRubyVersion: 2.3
|
9
|
+
Exclude:
|
10
|
+
- 'maestrano-connector-rails.gemspec'
|
11
|
+
- 'db/schema.rb'
|
12
|
+
- 'db/migrate/*'
|
13
|
+
- 'bin/*'
|
14
|
+
- 'spec/**/*'
|
15
|
+
- 'template/**/*'
|
16
|
+
- 'lib/generators/connector/**/*'
|
17
|
+
|
18
|
+
# Enabled disabled Cops
|
19
|
+
Style/CollectionMethods:
|
20
|
+
Enabled: true
|
21
|
+
|
22
|
+
Metrics/LineLength:
|
23
|
+
Max: 320
|
24
|
+
|
25
|
+
Style/IndentationConsistency:
|
26
|
+
EnforcedStyle: rails
|
27
|
+
|
28
|
+
# Missing top-level class documentation comment
|
29
|
+
Style/Documentation:
|
30
|
+
Enabled: false
|
31
|
+
|
32
|
+
Style/ClassAndModuleChildren:
|
33
|
+
Enabled: false
|
34
|
+
|
35
|
+
# Space inside braces => only for blocks (not for literal)
|
36
|
+
Style/SpaceInsideHashLiteralBraces:
|
37
|
+
EnforcedStyle: no_space
|
38
|
+
|
39
|
+
# RSpec/FilePath:
|
40
|
+
# Exclude:
|
41
|
+
# - 'spec/routing/**/*_routing_spec.rb'
|
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,180 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2016-07-05 12:03:48 +0100 using RuboCop version 0.41.1.
|
4
|
+
# The point is for the user to remove these configuration records
|
5
|
+
# one by one as the offenses are removed from the code base.
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
8
|
+
|
9
|
+
# Offense count: 1
|
10
|
+
# Configuration parameters: AllowSafeAssignment.
|
11
|
+
Lint/AssignmentInCondition:
|
12
|
+
Exclude:
|
13
|
+
- 'app/jobs/maestrano/connector/rails/push_to_connec_job.rb'
|
14
|
+
|
15
|
+
# Offense count: 1
|
16
|
+
# Cop supports --auto-correct.
|
17
|
+
# Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments.
|
18
|
+
Lint/UnusedBlockArgument:
|
19
|
+
Exclude:
|
20
|
+
- 'app/jobs/maestrano/connector/rails/synchronization_job.rb'
|
21
|
+
|
22
|
+
# Offense count: 14
|
23
|
+
# Cop supports --auto-correct.
|
24
|
+
# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods.
|
25
|
+
Lint/UnusedMethodArgument:
|
26
|
+
Exclude:
|
27
|
+
- 'app/jobs/maestrano/connector/rails/all_synchronizations_job.rb'
|
28
|
+
- 'app/models/maestrano/connector/rails/concerns/complex_entity.rb'
|
29
|
+
- 'app/models/maestrano/connector/rails/concerns/entity.rb'
|
30
|
+
- 'app/models/maestrano/connector/rails/concerns/external.rb'
|
31
|
+
|
32
|
+
# Offense count: 21
|
33
|
+
Metrics/AbcSize:
|
34
|
+
Max: 70
|
35
|
+
|
36
|
+
# Offense count: 9
|
37
|
+
Metrics/CyclomaticComplexity:
|
38
|
+
Max: 14
|
39
|
+
|
40
|
+
# Offense count: 40
|
41
|
+
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes.
|
42
|
+
# URISchemes: http, https
|
43
|
+
Metrics/LineLength:
|
44
|
+
Max: 311
|
45
|
+
|
46
|
+
# Offense count: 16
|
47
|
+
# Configuration parameters: CountComments.
|
48
|
+
Metrics/MethodLength:
|
49
|
+
Max: 42
|
50
|
+
|
51
|
+
# Offense count: 1
|
52
|
+
# Configuration parameters: CountComments.
|
53
|
+
Metrics/ModuleLength:
|
54
|
+
Max: 249
|
55
|
+
|
56
|
+
# Offense count: 2
|
57
|
+
# Configuration parameters: CountKeywordArgs.
|
58
|
+
Metrics/ParameterLists:
|
59
|
+
Max: 7
|
60
|
+
|
61
|
+
# Offense count: 10
|
62
|
+
Metrics/PerceivedComplexity:
|
63
|
+
Max: 15
|
64
|
+
|
65
|
+
# Offense count: 2
|
66
|
+
# Cop supports --auto-correct.
|
67
|
+
# Configuration parameters: EnabledForFlattenWithoutParams.
|
68
|
+
Performance/FlatMap:
|
69
|
+
Exclude:
|
70
|
+
- 'app/models/maestrano/connector/rails/concerns/complex_entity.rb'
|
71
|
+
|
72
|
+
# Offense count: 6
|
73
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
74
|
+
# SupportedStyles: strict, flexible
|
75
|
+
Rails/TimeZone:
|
76
|
+
Exclude:
|
77
|
+
- 'app/jobs/maestrano/connector/rails/synchronization_job.rb'
|
78
|
+
- 'app/models/maestrano/connector/rails/concerns/entity.rb'
|
79
|
+
|
80
|
+
# Offense count: 1
|
81
|
+
Style/AccessorMethodName:
|
82
|
+
Exclude:
|
83
|
+
- 'app/models/maestrano/connector/rails/synchronization.rb'
|
84
|
+
|
85
|
+
# Offense count: 3
|
86
|
+
# Cop supports --auto-correct.
|
87
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles, ProceduralMethods, FunctionalMethods, IgnoredMethods.
|
88
|
+
# SupportedStyles: line_count_based, semantic, braces_for_chaining
|
89
|
+
# ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object
|
90
|
+
# FunctionalMethods: let, let!, subject, watch
|
91
|
+
# IgnoredMethods: lambda, proc, it
|
92
|
+
Style/BlockDelimiters:
|
93
|
+
Exclude:
|
94
|
+
- 'app/models/maestrano/connector/rails/concerns/entity.rb'
|
95
|
+
|
96
|
+
# Offense count: 2
|
97
|
+
Style/ClassVars:
|
98
|
+
Exclude:
|
99
|
+
- 'app/models/maestrano/connector/rails/concerns/connec_helper.rb'
|
100
|
+
|
101
|
+
# Offense count: 2
|
102
|
+
# Cop supports --auto-correct.
|
103
|
+
# Configuration parameters: PreferredMethods.
|
104
|
+
Style/CollectionMethods:
|
105
|
+
Exclude:
|
106
|
+
- 'app/models/maestrano/connector/rails/concerns/complex_entity.rb'
|
107
|
+
|
108
|
+
# Offense count: 1
|
109
|
+
Style/DoubleNegation:
|
110
|
+
Exclude:
|
111
|
+
- 'app/controllers/maestrano/auth/saml_controller.rb'
|
112
|
+
|
113
|
+
# Offense count: 1
|
114
|
+
# Cop supports --auto-correct.
|
115
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
116
|
+
# SupportedStyles: empty_lines, no_empty_lines
|
117
|
+
Style/EmptyLinesAroundModuleBody:
|
118
|
+
Exclude:
|
119
|
+
- 'app/jobs/maestrano/connector/rails/push_to_connec_worker.rb'
|
120
|
+
|
121
|
+
# Offense count: 38
|
122
|
+
# Cop supports --auto-correct.
|
123
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
124
|
+
# SupportedStyles: when_needed, always
|
125
|
+
Style/FrozenStringLiteralComment:
|
126
|
+
Enabled: false
|
127
|
+
|
128
|
+
# Offense count: 3
|
129
|
+
# Configuration parameters: NamePrefix, NamePrefixBlacklist, NameWhitelist.
|
130
|
+
# NamePrefix: is_, has_, have_
|
131
|
+
# NamePrefixBlacklist: is_, has_, have_
|
132
|
+
# NameWhitelist: is_a?
|
133
|
+
Style/PredicateName:
|
134
|
+
Exclude:
|
135
|
+
- 'spec/**/*'
|
136
|
+
- 'app/helpers/maestrano/connector/rails/session_helper.rb'
|
137
|
+
- 'app/models/maestrano/connector/rails/concerns/entity.rb'
|
138
|
+
|
139
|
+
# Offense count: 1
|
140
|
+
# Cop supports --auto-correct.
|
141
|
+
# Configuration parameters: AllowMultipleReturnValues.
|
142
|
+
Style/RedundantReturn:
|
143
|
+
Exclude:
|
144
|
+
- 'app/jobs/maestrano/connector/rails/push_to_connec_worker.rb'
|
145
|
+
|
146
|
+
# Offense count: 1
|
147
|
+
# Cop supports --auto-correct.
|
148
|
+
Style/RedundantSelf:
|
149
|
+
Exclude:
|
150
|
+
- 'app/models/maestrano/connector/rails/organization.rb'
|
151
|
+
|
152
|
+
# Offense count: 1
|
153
|
+
# Cop supports --auto-correct.
|
154
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles, AllowInnerSlashes.
|
155
|
+
# SupportedStyles: slashes, percent_r, mixed
|
156
|
+
Style/RegexpLiteral:
|
157
|
+
Exclude:
|
158
|
+
- 'app/models/maestrano/connector/rails/concerns/entity.rb'
|
159
|
+
|
160
|
+
# Offense count: 3
|
161
|
+
# Cop supports --auto-correct.
|
162
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles, ConsistentQuotesInMultiline.
|
163
|
+
# SupportedStyles: single_quotes, double_quotes
|
164
|
+
Style/StringLiterals:
|
165
|
+
Exclude:
|
166
|
+
- 'app/controllers/maestrano/synchronizations_controller.rb'
|
167
|
+
|
168
|
+
# Offense count: 1
|
169
|
+
# Cop supports --auto-correct.
|
170
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
171
|
+
# SupportedStyles: final_newline, final_blank_line
|
172
|
+
Style/TrailingBlankLines:
|
173
|
+
Exclude:
|
174
|
+
- 'app/helpers/maestrano/connector/rails/session_helper.rb'
|
175
|
+
|
176
|
+
# Offense count: 1
|
177
|
+
# Cop supports --auto-correct.
|
178
|
+
Style/TrailingWhitespace:
|
179
|
+
Exclude:
|
180
|
+
- 'app/jobs/maestrano/connector/rails/synchronization_job.rb'
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
2.3.1@maestrano-connector-rails
|
data/CODESHIP.md
CHANGED
data/Gemfile
CHANGED
@@ -1,28 +1,34 @@
|
|
1
|
-
source
|
1
|
+
source 'http://rubygems.org'
|
2
2
|
|
3
3
|
# Add dependencies required to use your gem here.
|
4
|
-
gem 'rails', '~> 4.
|
4
|
+
gem 'rails', '~> 4.2'
|
5
5
|
gem 'maestrano-rails'
|
6
6
|
gem 'hash_mapper'
|
7
|
-
gem 'sidekiq'
|
8
|
-
# The missing unique jobs for sidekiq
|
9
|
-
gem 'sidekiq-unique-jobs'
|
10
7
|
gem 'haml-rails'
|
11
8
|
gem 'bootstrap-sass'
|
12
9
|
gem 'autoprefixer-rails'
|
13
10
|
gem 'attr_encrypted', '~> 1.4.0'
|
14
11
|
gem 'config'
|
12
|
+
gem 'figaro'
|
13
|
+
|
14
|
+
gem 'sidekiq'
|
15
|
+
# The missing unique jobs for sidekiq
|
16
|
+
gem 'sidekiq-unique-jobs'
|
17
|
+
gem 'sinatra', require: nil
|
18
|
+
gem 'sidekiq-cron'
|
19
|
+
gem 'slim'
|
15
20
|
|
16
21
|
# Add dependencies to develop your gem here.
|
17
22
|
group :development do
|
18
|
-
gem
|
19
|
-
gem
|
20
|
-
gem
|
21
|
-
gem
|
22
|
-
gem
|
23
|
+
gem 'shoulda', '>= 0'
|
24
|
+
gem 'rdoc', '~> 3.12'
|
25
|
+
gem 'bundler', '~> 1.0'
|
26
|
+
gem 'jeweler', '~> 2.1.1'
|
27
|
+
gem 'simplecov', '>= 0'
|
23
28
|
gem 'rspec-rails'
|
24
29
|
gem 'factory_girl_rails'
|
25
30
|
gem 'sqlite3'
|
26
31
|
gem 'shoulda-matchers'
|
32
|
+
gem 'rubocop'
|
27
33
|
gem 'timecop'
|
28
34
|
end
|
data/Rakefile
CHANGED
@@ -6,7 +6,7 @@ begin
|
|
6
6
|
Bundler.setup(:default, :development)
|
7
7
|
rescue Bundler::BundlerError => e
|
8
8
|
$stderr.puts e.message
|
9
|
-
$stderr.puts
|
9
|
+
$stderr.puts 'Run `bundle install` to install missing gems'
|
10
10
|
exit e.status_code
|
11
11
|
end
|
12
12
|
require 'rake'
|
@@ -14,24 +14,24 @@ require 'rake'
|
|
14
14
|
require 'jeweler'
|
15
15
|
Jeweler::Tasks.new do |gem|
|
16
16
|
# gem is a Gem::Specification... see http://guides.rubygems.org/specification-reference/ for more options
|
17
|
-
gem.name =
|
18
|
-
gem.homepage =
|
19
|
-
gem.license =
|
20
|
-
gem.summary =
|
21
|
-
gem.description =
|
22
|
-
gem.email =
|
23
|
-
gem.authors = [
|
17
|
+
gem.name = 'maestrano-connector-rails'
|
18
|
+
gem.homepage = 'http://github.com/maestrano/maestrano-connector-rails'
|
19
|
+
gem.license = 'MIT'
|
20
|
+
gem.summary = 'Rails framework to build connector with Maestrano'
|
21
|
+
gem.description = 'Maestrano is the next generation marketplace for SME applications. See https://maestrano.com for details.'
|
22
|
+
gem.email = 'pierre.berard@maestrano.com'
|
23
|
+
gem.authors = ['Pierre Berard']
|
24
24
|
# dependencies defined in Gemfile
|
25
25
|
end
|
26
26
|
Jeweler::RubygemsDotOrgTasks.new
|
27
27
|
|
28
|
-
APP_RAKEFILE = File.expand_path(
|
28
|
+
APP_RAKEFILE = File.expand_path('../spec/dummy/Rakefile', __FILE__)
|
29
29
|
load 'rails/tasks/engine.rake'
|
30
30
|
|
31
31
|
require 'rspec/core'
|
32
32
|
require 'rspec/core/rake_task'
|
33
33
|
|
34
|
-
desc
|
35
|
-
RSpec::Core::RakeTask.new(:
|
34
|
+
desc 'Run all specs in spec directory (excluding plugin specs)'
|
35
|
+
RSpec::Core::RakeTask.new(spec: 'app:db:test:prepare')
|
36
36
|
|
37
|
-
task :
|
37
|
+
task default: :spec
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.2.
|
1
|
+
1.2.2
|
@@ -1,20 +1,18 @@
|
|
1
1
|
class Maestrano::Account::GroupUsersController < Maestrano::Rails::WebHookController
|
2
|
-
|
3
|
-
# DELETE /maestrano/account/groups/cld-1/users/usr-1
|
4
2
|
# DELETE /maestrano/account/groups/cld-1/users/usr-1/tenant
|
5
3
|
# Remove a user from a group
|
6
4
|
def destroy
|
7
5
|
# Set the right uid based on Maestrano.param('sso.creation_mode')
|
8
|
-
user_uid = Maestrano.mask_user(params[:id], params[:group_id])
|
6
|
+
user_uid = Maestrano.mask_user(params[:id], params[:group_id])
|
9
7
|
group_uid = params[:group_id]
|
10
|
-
|
8
|
+
|
11
9
|
# Get the entities
|
12
10
|
user = Maestrano::Connector::Rails::User.find_by_uid_and_tenant(user_uid, params[:tenant] || 'default')
|
13
11
|
organization = Maestrano::Connector::Rails::Organization.find_by_uid_and_tenant(group_uid, params[:tenant] || 'default')
|
14
|
-
|
12
|
+
|
15
13
|
# Remove the user from the organization
|
16
14
|
organization.remove_member(user)
|
17
|
-
|
15
|
+
|
18
16
|
render json: {success: true}
|
19
17
|
end
|
20
|
-
end
|
18
|
+
end
|
@@ -1,22 +1,20 @@
|
|
1
1
|
class Maestrano::Account::GroupsController < Maestrano::Rails::WebHookController
|
2
|
-
|
3
|
-
# DELETE /maestrano/account/groups/cld-1
|
4
2
|
# DELETE /maestrano/account/groups/cld-1/tenant
|
5
3
|
# Delete an entire group
|
6
4
|
def destroy
|
7
5
|
# id
|
8
6
|
org_uid = params[:id]
|
9
|
-
|
7
|
+
|
10
8
|
# Get entity
|
11
9
|
organization = Maestrano::Connector::Rails::Organization.find_by_uid_and_tenant(org_uid, params[:tenant] || 'default')
|
12
|
-
|
10
|
+
|
13
11
|
# Delete all relations
|
14
12
|
organization.user_organization_rels.delete_all
|
15
|
-
|
13
|
+
|
16
14
|
# Delete the organization
|
17
15
|
organization.destroy
|
18
|
-
|
16
|
+
|
19
17
|
# Respond
|
20
18
|
render json: {success: true}
|
21
19
|
end
|
22
|
-
end
|
20
|
+
end
|
@@ -1,5 +1,4 @@
|
|
1
1
|
class Maestrano::Auth::SamlController < Maestrano::Rails::SamlBaseController
|
2
|
-
|
3
2
|
def init
|
4
3
|
session[:settings] = !!params[:settings]
|
5
4
|
super
|
@@ -14,9 +13,7 @@ class Maestrano::Auth::SamlController < Maestrano::Rails::SamlBaseController
|
|
14
13
|
user = Maestrano::Connector::Rails::User.find_or_create_for_maestrano(user_auth_hash, params[:tenant])
|
15
14
|
organization = Maestrano::Connector::Rails::Organization.find_or_create_for_maestrano(group_auth_hash, params[:tenant])
|
16
15
|
if user && organization
|
17
|
-
unless organization.member?(user)
|
18
|
-
organization.add_member(user)
|
19
|
-
end
|
16
|
+
organization.add_member(user) unless organization.member?(user)
|
20
17
|
|
21
18
|
session[:tenant] = params[:tenant]
|
22
19
|
session[:uid] = user.uid
|
@@ -27,12 +24,10 @@ class Maestrano::Auth::SamlController < Maestrano::Rails::SamlBaseController
|
|
27
24
|
if session[:settings]
|
28
25
|
session.delete(:settings)
|
29
26
|
redirect_to main_app.root_path
|
27
|
+
elsif current_organization && current_organization.oauth_uid && current_organization.sync_enabled
|
28
|
+
redirect_to main_app.home_redirect_to_external_path
|
30
29
|
else
|
31
|
-
|
32
|
-
redirect_to main_app.home_redirect_to_external_path
|
33
|
-
else
|
34
|
-
redirect_to main_app.root_path
|
35
|
-
end
|
30
|
+
redirect_to main_app.root_path
|
36
31
|
end
|
37
32
|
end
|
38
|
-
end
|
33
|
+
end
|
@@ -1,11 +1,9 @@
|
|
1
1
|
class Maestrano::ConnecController < Maestrano::Rails::WebHookController
|
2
|
-
|
3
2
|
def notifications
|
4
3
|
Rails.logger.debug "Received notification from Connec!: #{params}"
|
5
4
|
|
6
5
|
begin
|
7
6
|
params.except(:tenant, :controller, :action, :connec).each do |entity_name, entities|
|
8
|
-
|
9
7
|
entity_class_hash = find_entity_class(entity_name)
|
10
8
|
next Rails.logger.info "Received notification from Connec! for unknow entity: #{entity_name}" unless entity_class_hash
|
11
9
|
|
@@ -14,7 +12,6 @@ class Maestrano::ConnecController < Maestrano::Rails::WebHookController
|
|
14
12
|
next Rails.logger.warn "Received notification from Connec! for unknown group or group without oauth: #{entity['group_id']} (tenant: #{params[:tenant]})" unless organization && organization.oauth_uid
|
15
13
|
next unless organization.sync_enabled && organization.synchronized_entities[entity_class_hash[:name].to_sym]
|
16
14
|
|
17
|
-
|
18
15
|
Maestrano::Connector::Rails::ConnectorLogger.log('info', organization, "Received entity from Connec! webhook: Entity=#{entity_name}, Data=#{entity}")
|
19
16
|
connec_client = Maestrano::Connector::Rails::ConnecHelper.get_client(organization)
|
20
17
|
external_client = Maestrano::Connector::Rails::External.get_client(organization)
|
@@ -22,11 +19,14 @@ class Maestrano::ConnecController < Maestrano::Rails::WebHookController
|
|
22
19
|
|
23
20
|
entity_instance = entity_class_hash[:class].new(organization, connec_client, external_client, {})
|
24
21
|
entity_instance.before_sync(last_synchronization_date)
|
25
|
-
|
22
|
+
|
26
23
|
# Build expected input for consolidate_and_map_data
|
27
24
|
if entity_class_hash[:is_complex]
|
28
|
-
|
29
|
-
|
25
|
+
connec_hash_of_entities = Maestrano::Connector::Rails::ComplexEntity.build_hash_with_entities(entity_instance.class.connec_entities_names, entity_name, ->(name) { name.parameterize('_').pluralize }, [entity])
|
26
|
+
filtered_entities = entity_instance.filter_connec_entities(connec_hash_of_entities)
|
27
|
+
|
28
|
+
empty_external_hash = Maestrano::Connector::Rails::ComplexEntity.build_empty_hash(entity_instance.class.external_entities_names)
|
29
|
+
mapped_entity = entity_instance.consolidate_and_map_data(filtered_entities, empty_external_hash)
|
30
30
|
else
|
31
31
|
filtered_entities = entity_instance.filter_connec_entities([entity])
|
32
32
|
mapped_entity = entity_instance.consolidate_and_map_data(filtered_entities, [])
|
@@ -40,18 +40,19 @@ class Maestrano::ConnecController < Maestrano::Rails::WebHookController
|
|
40
40
|
Rails.logger.warn("error processing notification #{e.message} - #{e.backtrace.join("\n")}")
|
41
41
|
end
|
42
42
|
|
43
|
-
head 200, content_type:
|
43
|
+
head 200, content_type: 'application/json'
|
44
44
|
end
|
45
45
|
|
46
|
-
|
47
46
|
private
|
47
|
+
|
48
48
|
def find_entity_class(entity_name)
|
49
49
|
Maestrano::Connector::Rails::External.entities_list.each do |entity_name_from_list|
|
50
50
|
clazz = "Entities::#{entity_name_from_list.singularize.titleize.split.join}".constantize
|
51
51
|
if clazz.methods.include?('connec_entities_names'.to_sym)
|
52
|
-
|
53
|
-
|
54
|
-
|
52
|
+
formatted_entities_names = clazz.connec_entities_names.map { |n| n.parameterize('_').pluralize }
|
53
|
+
return {class: clazz, is_complex: true, name: entity_name_from_list} if formatted_entities_names.include?(entity_name)
|
54
|
+
elsif clazz.methods.include?('connec_entity_name'.to_sym) && clazz.normalized_connec_entity_name == entity_name
|
55
|
+
return {class: clazz, is_complex: false, name: entity_name_from_list}
|
55
56
|
end
|
56
57
|
end
|
57
58
|
nil
|