pampa_workers 1.1.10 → 1.1.16

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/client.rb +36 -27
  3. data/lib/mybotprocess.rb +6 -6
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ff32f498a9f417bca1cd87cf09b5a834d6682d02
4
- data.tar.gz: e078e98d93b15003592bd75c63615ae04cc97add
3
+ metadata.gz: d220ce3a1a32528fef038c7b6e3682b7e2b4dea4
4
+ data.tar.gz: f9fa423fb8833f6bd4ce4d33d764565269e58c44
5
5
  SHA512:
6
- metadata.gz: 495dd61d71142f0c760624819b78693647b4251c870fab166694cb1c55f1a8b8debdda627a08aa1c9513b131bd51b9d1deff9cd8fd89af20b12e44f55d2be589
7
- data.tar.gz: be9351da878c5670bdf8836ec79781395225a23dc6d632b6312d67084ff7eaa6d2c5c07f095013b03b8cd6f260e9bb312cde3d622d10bdccec103d99e63c16b7
6
+ metadata.gz: d6fa838696c0ecbe59466d33e04f4c01ccca4bd56d8dcdd6699dada04ecca6ed4bfa0764900736f2433a84be45c450f8c52d080759a321b1e299c9df4aa212ae
7
+ data.tar.gz: fc6dcc979f8e005c2a6c7409cdd546fcf45bea6c2d581c7d3f2dce09bc181311c6bb86bdef7a94f4f142c5f7f9e205a295d273083c8ed65f349187b45738014a
@@ -10,7 +10,7 @@ module BlackStack
10
10
  one_to_many :users, :class=>:'BlackStack::User', :key=>:id_client
11
11
  many_to_one :timezone, :class=>:'BlackStack::Timezone', :key=>:id_timezone
12
12
  many_to_one :billingCountry, :class=>:'BlackStack::LnCountry', :key=>:billing_id_lncountry
13
- many_to_one :user_to_contect, :class=>'BlackStack:::User', :key=>:id_user_to_contact
13
+ many_to_one :user_to_contect, :class=>'BlackStack::User', :key=>:id_user_to_contact
14
14
 
15
15
 
16
16
  # -----------------------------------------------------------------------------------------
@@ -85,50 +85,59 @@ module BlackStack
85
85
 
86
86
  # llama a la api de postmark preguntando el reseller email configurado para este clietne fue ferificado
87
87
  def checkDomainForSSMVerified()
88
- return_message = {}
88
+ return_message = {}
89
89
  domain = self.domain_for_ssm
90
90
  email = self.from_email_for_ssm
91
91
  id = ''
92
92
  client = ''
93
-
94
93
  if domain != nil && email != nil
95
94
  begin
96
- client_postmark = Postmark::AccountApiClient.new(POSTMARK_API_TOKEN, secure: true)
97
- client_list = client_postmark.get_signatures()
98
-
99
- client_list.each do |sign|
100
- if sign[:domain] == domain
101
- if sign[:email_address] == email
102
- id = sign[:id]
103
- break
104
- end
105
- end
106
- end
107
-
108
- if id.to_s.size > 0
109
- client = client_postmark.get_sender(id)
95
+ # create postmark client
96
+ client_postmark = Postmark::AccountApiClient.new(POSTMARK_API_TOKEN, secure: true)
97
+
98
+ # get signature
99
+ # more info: https://github.com/wildbit/postmark-gem/wiki/Senders
100
+ #
101
+ # this first strategy is not scalable if we handle a large list of signatures.
102
+ #sign = client_postmark.signatures.select { |sign| sign[:domain]==domain }.first
103
+ #
104
+ # this other approach is a bit more scalable, but anyway we need to call the API
105
+ # with filering by the domain.
106
+ #
107
+ pagesize = 30 # TODO: increase this value to 300 for optimization
108
+ i = 0
109
+ j = 1
110
+ sign = nil
111
+ while j>0 && sign.nil?
112
+ buff = client_postmark.get_signatures(offset: i, count: pagesize)
113
+ j = buff.size
114
+ i += pagesize
115
+ sign = buff.select { |s| s[:domain]==domain }.first
116
+ end # while
117
+
118
+ # if signature has been found?
119
+ if sign.nil?
120
+ # sincronizo con la central
121
+ return_message[:status] = "Client Signature Not Found"
122
+ return_message[:value] = client[:id]
123
+ return return_message.to_json
124
+ else
125
+ id = sign[:id]
126
+ client = client_postmark.get_sender(id)
110
127
  if !client[:confirmed]
111
128
  self.domain_for_ssm_verified = false
112
- self.save
113
-
129
+ self.save
114
130
  return_message[:status] = "No Verified"
115
131
  return_message[:value] = client[:id]
116
-
117
132
  return return_message.to_json
118
133
  else
119
134
  self.domain_for_ssm_verified = true
120
- self.save
121
-
122
- # sincronizo con la central
123
- return_message = {}
124
-
135
+ self.save
125
136
  return_message[:status] = "success"
126
137
  return_message[:value] = client[:id]
127
-
128
138
  return return_message.to_json
129
139
  end
130
140
  end
131
-
132
141
  rescue Postmark::ApiInputError => e
133
142
  return_message[:status] = e.to_s
134
143
  return return_message.to_json
@@ -113,14 +113,14 @@ module BlackStack
113
113
  url =
114
114
  "#{BlackStack::Pampa::api_protocol}://#{self.ws_url}:#{self.ws_port}/api1.3/pampa/scrape.inbox/notify_lnchat.json?" +
115
115
  "api_key=#{BlackStack::Pampa::api_key}&" +
116
- "profile_code=#{URI.escape(conv[:profile_code])}&" +
117
- "profile_name=#{URI.escape(conv[:profile_name])}&" +
118
- "profile_headline=#{URI.escape(conv[:profile_headline])}&" +
119
- "first=#{URI.escape(conv[:first])}&" +
116
+ "profile_code=#{CGI.escape(conv[:profile_code])}&" +
117
+ "profile_name=#{CGI.escape(conv[:profile_name])}&" +
118
+ "profile_headline=#{CGI.escape(conv[:profile_headline])}&" +
119
+ "first=#{CGI.escape(conv[:first])}&" +
120
120
  "position=#{chat[:position].to_s}&" +
121
121
  "uid=#{lnuser['id']}&" +
122
- "sender_name=#{URI.escape(chat[:sender_name])}&" +
123
- "body=#{URI.escape(chat[:body])}&"
122
+ "sender_name=#{CGI.escape(chat[:sender_name])}&" +
123
+ "body=#{CGI.escape(chat[:body])}&"
124
124
  puts ""
125
125
  puts "url:#{url}:."
126
126
  puts ""
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pampa_workers
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.10
4
+ version: 1.1.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leandro Daniel Sardi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-09 00:00:00.000000000 Z
11
+ date: 2020-07-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: websocket