瀏覽代碼

Uses correct scopes for google API based on config.js values. (#5066)

* Uses correct scopes for google API based on config.js values.

* Lower the number of parameters that we pass around.

* Fixes googleAPIState state checking.
master
Дамян Минков 5 年之前
父節點
當前提交
9bb789472e
沒有連結到貢獻者的電子郵件帳戶。

+ 1
- 2
react/features/calendar-sync/actions.web.js 查看文件

46
         return Promise.resolve()
46
         return Promise.resolve()
47
             .then(() => {
47
             .then(() => {
48
                 if (googleApiApplicationClientID) {
48
                 if (googleApiApplicationClientID) {
49
-                    return dispatch(
50
-                        loadGoogleAPI(googleApiApplicationClientID));
49
+                    return dispatch(loadGoogleAPI());
51
                 }
50
                 }
52
             })
51
             })
53
             .then(() => {
52
             .then(() => {

+ 1
- 6
react/features/calendar-sync/web/googleCalendar.js 查看文件

43
      * @returns {function(Dispatch<any>, Function): Promise<void>}
43
      * @returns {function(Dispatch<any>, Function): Promise<void>}
44
      */
44
      */
45
     load() {
45
     load() {
46
-        return (dispatch: Dispatch<any>, getState: Function) => {
47
-            const { googleApiApplicationClientID }
48
-                = getState()['features/base/config'];
49
-
50
-            return dispatch(loadGoogleAPI(googleApiApplicationClientID));
51
-        };
46
+        return (dispatch: Dispatch<any>) => dispatch(loadGoogleAPI());
52
     },
47
     },
53
 
48
 
54
     /**
49
     /**

+ 9
- 3
react/features/google-api/actions.js 查看文件

29
 /**
29
 /**
30
  * Loads Google API.
30
  * Loads Google API.
31
  *
31
  *
32
- * @param {string} clientId - The client ID to be used with the API library.
33
  * @returns {Function}
32
  * @returns {Function}
34
  */
33
  */
35
-export function loadGoogleAPI(clientId: string) {
34
+export function loadGoogleAPI() {
36
     return (dispatch: Dispatch<any>, getState: Function) =>
35
     return (dispatch: Dispatch<any>, getState: Function) =>
37
         googleApi.get()
36
         googleApi.get()
38
         .then(() => {
37
         .then(() => {
38
+            const {
39
+                liveStreamingEnabled,
40
+                enableCalendarIntegration,
41
+                googleApiApplicationClientID
42
+            } = getState()['features/base/config'];
43
+
39
             if (getState()['features/google-api'].googleAPIState
44
             if (getState()['features/google-api'].googleAPIState
40
                     === GOOGLE_API_STATES.NEEDS_LOADING) {
45
                     === GOOGLE_API_STATES.NEEDS_LOADING) {
41
-                return googleApi.initializeClient(clientId);
46
+                return googleApi.initializeClient(
47
+                    googleApiApplicationClientID, liveStreamingEnabled, enableCalendarIntegration);
42
             }
48
             }
43
 
49
 
44
             return Promise.resolve();
50
             return Promise.resolve();

+ 8
- 5
react/features/google-api/googleApi.web.js 查看文件

61
      * making Google API requests.
61
      * making Google API requests.
62
      *
62
      *
63
      * @param {string} clientId - The client ID to be used with the API library.
63
      * @param {string} clientId - The client ID to be used with the API library.
64
+     * @param {boolean} enableYoutube - Whether youtube scope is enabled.
65
+     * @param {boolean} enableCalendar - Whether calendar scope is enabled.
64
      * @returns {Promise}
66
      * @returns {Promise}
65
      */
67
      */
66
-    initializeClient(clientId) {
68
+    initializeClient(clientId, enableYoutube, enableCalendar) {
67
         return this.get()
69
         return this.get()
68
             .then(api => new Promise((resolve, reject) => {
70
             .then(api => new Promise((resolve, reject) => {
71
+                const scope
72
+                    = `${enableYoutube ? GOOGLE_SCOPE_YOUTUBE : ''} ${enableCalendar ? GOOGLE_SCOPE_CALENDAR : ''}`
73
+                        .trim();
74
+
69
                 // setTimeout is used as a workaround for api.client.init not
75
                 // setTimeout is used as a workaround for api.client.init not
70
                 // resolving consistently when the Google API Client Library is
76
                 // resolving consistently when the Google API Client Library is
71
                 // loaded asynchronously. See:
77
                 // loaded asynchronously. See:
74
                     api.client.init({
80
                     api.client.init({
75
                         clientId,
81
                         clientId,
76
                         discoveryDocs: DISCOVERY_DOCS,
82
                         discoveryDocs: DISCOVERY_DOCS,
77
-                        scope: [
78
-                            GOOGLE_SCOPE_CALENDAR,
79
-                            GOOGLE_SCOPE_YOUTUBE
80
-                        ].join(' ')
83
+                        scope
81
                     })
84
                     })
82
                     .then(resolve)
85
                     .then(resolve)
83
                     .catch(reject);
86
                     .catch(reject);

+ 1
- 2
react/features/recording/components/LiveStream/web/StartLiveStreamDialog.js 查看文件

121
      * @returns {void}
121
      * @returns {void}
122
      */
122
      */
123
     _onInitializeGoogleApi() {
123
     _onInitializeGoogleApi() {
124
-        this.props.dispatch(
125
-            loadGoogleAPI(this.props._googleApiApplicationClientID))
124
+        this.props.dispatch(loadGoogleAPI())
126
         .catch(response => this._parseErrorFromResponse(response));
125
         .catch(response => this._parseErrorFromResponse(response));
127
     }
126
     }
128
 
127
 

Loading…
取消
儲存