key:
"getRegistrationInfo"
,
value: function(feature, apiClient, options) {
var params
=
{
serverId: apiClient.serverId(),
deviceId: this.deviceId(),
deviceName: this.deviceName(),
appName: this.appName(),
appVersion: this.appVersion(),
embyUserName: ""
};
(options
=
options || {}).viewOnly && (params.viewOnly
=
options.viewOnly);
var cacheKey
=
getCacheKey(feature, apiClient, options),
regInfo
=
JSON.parse(this.appStorage.getItem(cacheKey) ||
"{}"
),
timeSinceLastValidation
=
Date.now()
-
(regInfo.lastValidDate ||
0
);
if
(timeSinceLastValidation <
=
864e5
)
return
console.log(
"getRegistrationInfo returning cached info"
), Promise.resolve();
var regCacheValid
=
timeSinceLastValidation <
=
864e5
*
(regInfo.cacheExpirationDays ||
7
);
params.embyUserName
=
apiClient.getCurrentUserName();
var currentUserId
=
apiClient.getCurrentUserId();
if
(currentUserId &&
"81f53802ea0247ad80618f55d9b4ec3c"
=
=
=
currentUserId.toLowerCase() &&
"21585256623b4beeb26d5d3b09dec0ac"
=
=
=
params.serverId.toLowerCase())
return
Promise.reject();
var appStorage
=
this.appStorage,
getRegPromise
=
ajax({
url:
"98cK9s2c8@1M7s2y4Q4x3@1q4Q4x3V1k6Q4x3V1k6E0j5U0y4S2k6r3#2A6L8W2)9J5k6h3y4G2L8g2)9J5c8X3q4V1L8h3W2F1i4K6u0r3M7$3g2J5N6X3W2U0k6g2)9J5c8Y4u0W2k6$3W2K6N6s2u0S2N6r3W2G2L8W2)9J5c8Y4k6S2L8r3W2V1j5i4c8W2c8r3g2$3K9h3y4W2i4K6y4r3"
+
paramsToString(params),
type
:
"POST"
,
dataType:
"json"
}).then(function(response) {
return
appStorage.setItem(cacheKey, JSON.stringify({
lastValidDate: Date.now(),
deviceId: params.deviceId,
cacheExpirationDays: response.cacheExpirationDays
})), Promise.resolve()
}, function(response) {
var status
=
(response || {}).status;
return
console.log(
"getRegistrationInfo response: "
+
status),
403
=
=
=
status ? Promise.reject(
"overlimit"
) : status && status <
500
? Promise.reject() : function(err) {
if
(console.log(
"getRegistrationInfo failed: "
+
err), regCacheValid)
return
console.log(
"getRegistrationInfo returning cached info"
), Promise.resolve();
throw err
}(response)
});
return
regCacheValid ? (console.log(
"getRegistrationInfo returning cached info"
), Promise.resolve()) : getRegPromise
}