@@ -23,6 +23,8 @@ import {
23
23
ProviderPlaylistObject ,
24
24
RequestLoader
25
25
} from '../../types' ;
26
+ import OVPUserService from './services/user-service' ;
27
+ import { KalturaUserGetResponse } from './response-types/kaltura-user-get-response' ;
26
28
27
29
export default class OVPProvider extends BaseProvider < OVPProviderMediaInfoObject > {
28
30
private _filterOptionsConfig : ProviderFilterOptionsObject = { redirectFromEntryId : true } ;
@@ -39,12 +41,29 @@ export default class OVPProvider extends BaseProvider<OVPProviderMediaInfoObject
39
41
this . _setFilterOptionsConfig ( options . filterOptions ) ;
40
42
this . _vrTag = options . vrTag || '360' ;
41
43
this . _networkRetryConfig = Object . assign ( this . _networkRetryConfig , options . networkRetryParameters ) ;
44
+
45
+ this . _isAnonymous = ! this . _ks ? true : undefined ;
46
+ if ( this . _isAnonymous === undefined ) {
47
+ this . initializeUserResponse ( OVPConfiguration . serviceUrl , this . _ks ) . then ( ( ) => {
48
+ this . _logger . info ( 'User response initialized' ) ;
49
+ } ) . catch ( err => {
50
+ this . _logger . error ( 'Failed to initialize user response' , err ) ;
51
+ } ) ;
52
+ }
42
53
}
43
54
44
55
public get env ( ) : any {
45
56
return OVPConfiguration . get ( ) ;
46
57
}
47
58
59
+ public async initializeUserResponse ( serviceUrl : string , ks : string ) : Promise < void > {
60
+ const request = OVPUserService . get ( serviceUrl , ks ) ;
61
+ request . params = JSON . stringify ( request . params ) ;
62
+ const response = await request . doHttpRequest ( ) ;
63
+ const userResponse = new KalturaUserGetResponse ( response ) ;
64
+ this . _isAnonymous = userResponse . isAnonymous ( ) ;
65
+ }
66
+
48
67
/**
49
68
* Gets the backend media config object.
50
69
* @param {OVPProviderMediaInfoObject } mediaInfo - ovp media info
@@ -53,10 +72,6 @@ export default class OVPProvider extends BaseProvider<OVPProviderMediaInfoObject
53
72
public getMediaConfig ( mediaInfo : OVPProviderMediaInfoObject ) : Promise < ProviderMediaConfigObject > {
54
73
if ( mediaInfo . ks ) {
55
74
this . ks = mediaInfo . ks ;
56
- this . _isAnonymous = false ;
57
- }
58
- if ( this . widgetId !== this . defaultWidgetId ) {
59
- this . _isAnonymous = false ;
60
75
}
61
76
this . _dataLoader = new OVPDataLoaderManager ( this . playerVersion , this . partnerId , this . ks , this . _networkRetryConfig ) ;
62
77
return new Promise ( ( resolve , reject ) => {
@@ -209,10 +224,6 @@ export default class OVPProvider extends BaseProvider<OVPProviderMediaInfoObject
209
224
public getPlaylistConfig ( playlistInfo : ProviderPlaylistInfoObject ) : Promise < ProviderPlaylistObject > {
210
225
if ( playlistInfo . ks ) {
211
226
this . ks = playlistInfo . ks ;
212
- this . _isAnonymous = false ;
213
- }
214
- if ( this . widgetId !== this . defaultWidgetId ) {
215
- this . _isAnonymous = false ;
216
227
}
217
228
this . _dataLoader = new OVPDataLoaderManager ( this . playerVersion , this . partnerId , this . ks , this . _networkRetryConfig ) ;
218
229
return new Promise ( ( resolve , reject ) => {
@@ -265,10 +276,6 @@ export default class OVPProvider extends BaseProvider<OVPProviderMediaInfoObject
265
276
public getEntryListConfig ( entryListInfo : ProviderEntryListObject ) : Promise < ProviderPlaylistObject > {
266
277
if ( entryListInfo . ks ) {
267
278
this . ks = entryListInfo . ks ;
268
- this . _isAnonymous = false ;
269
- }
270
- if ( this . widgetId !== this . defaultWidgetId ) {
271
- this . _isAnonymous = false ;
272
279
}
273
280
this . _dataLoader = new OVPDataLoaderManager ( this . playerVersion , this . partnerId , this . ks , this . _networkRetryConfig ) ;
274
281
return new Promise ( ( resolve , reject ) => {
0 commit comments