179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
|
# File 'lib/queueit_knownuserv3/known_user.rb', line 179
def self.validateRequestByIntegrationConfig(currentUrlWithoutQueueITToken, queueitToken, integrationsConfigString, customerId, secretKey, request)
if(Utils.isNilOrEmpty(currentUrlWithoutQueueITToken))
raise KnownUserError, "currentUrlWithoutQueueITToken can not be nil or empty."
end
if(Utils.isNilOrEmpty(integrationsConfigString))
raise KnownUserError, "integrationsConfigString can not be nil or empty."
end
begin
customerIntegration = JSON.parse(integrationsConfigString)
debugEntries = Hash.new
isDebug = getIsDebug(queueitToken, secretKey)
if(isDebug)
debugEntries["ConfigVersion"] = customerIntegration["Version"]
debugEntries["PureUrl"] = currentUrlWithoutQueueITToken
debugEntries["QueueitToken"] = queueitToken
debugEntries["OriginalUrl"] = request.original_url
end
integrationEvaluator = IntegrationEvaluator.new
matchedConfig = integrationEvaluator.getMatchedIntegrationConfig(customerIntegration, currentUrlWithoutQueueITToken, request)
if(isDebug)
if(matchedConfig == nil)
debugEntries["MatchedConfig"] = "NULL"
else
debugEntries["MatchedConfig"] = matchedConfig["Name"]
end
end
if(matchedConfig == nil)
return RequestValidationResult.new(nil, nil, nil, nil)
end
if(!matchedConfig.key?("ActionType") || Utils.isNilOrEmpty(matchedConfig["ActionType"]) || matchedConfig["ActionType"].eql?(ActionTypes::QUEUE))
queueConfig = QueueEventConfig.new
queueConfig.eventId = matchedConfig["EventId"]
queueConfig.queueDomain = matchedConfig["QueueDomain"]
queueConfig.layoutName = matchedConfig["LayoutName"]
queueConfig.culture = matchedConfig["Culture"]
queueConfig.cookieDomain = matchedConfig["CookieDomain"]
queueConfig.extendCookieValidity = matchedConfig["ExtendCookieValidity"]
queueConfig.cookieValidityMinute = matchedConfig["CookieValidityMinute"]
queueConfig.version = customerIntegration["Version"]
case matchedConfig["RedirectLogic"]
when "ForcedTargetUrl"
targetUrl = matchedConfig["ForcedTargetUrl"]
when "EventTargetUrl"
targetUrl = ''
else
targetUrl = currentUrlWithoutQueueITToken
end
return _resolveQueueRequestByLocalConfig(targetUrl, queueitToken, queueConfig, customerId, secretKey, request, debugEntries)
else
cancelConfig = CancelEventConfig.new;
cancelConfig.eventId = matchedConfig["EventId"]
cancelConfig.queueDomain = matchedConfig["QueueDomain"]
cancelConfig.cookieDomain = matchedConfig["CookieDomain"]
cancelConfig.version = customerIntegration["Version"]
return _cancelRequestByLocalConfig(currentUrlWithoutQueueITToken, queueitToken, cancelConfig, customerId, secretKey, request, debugEntries);
end
rescue StandardError => stdErr
raise KnownUserError, "integrationConfiguration text was not valid: " + stdErr.message
ensure
setDebugCookie(debugEntries, request.cookie_jar)
end
end
|