Quellcode durchsuchen

fix(vpaas): Count endpoint only when there are 2 or more participants

j8
Vlad Piersec vor 4 Jahren
Ursprung
Commit
59caa0cf42

+ 1
- 0
react/features/app/reducers.any.js Datei anzeigen

@@ -24,6 +24,7 @@ import '../base/sounds/reducer';
24 24
 import '../base/testing/reducer';
25 25
 import '../base/tracks/reducer';
26 26
 import '../base/user-interaction/reducer';
27
+import '../billing-counter/reducer';
27 28
 import '../blur/reducer';
28 29
 import '../calendar-sync/reducer';
29 30
 import '../chat/reducer';

+ 5
- 0
react/features/billing-counter/actionTypes.js Datei anzeigen

@@ -2,3 +2,8 @@
2 2
  * Action used to store the billing id.
3 3
  */
4 4
 export const SET_BILLING_ID = 'SET_BILLING_ID';
5
+
6
+/**
7
+ * Action used to store the flag signaling the endpoint has been counted.
8
+ */
9
+export const SET_ENDPOINT_COUNTED = 'SET_ENDPOINT_COUNTED';

+ 13
- 1
react/features/billing-counter/actions.js Datei anzeigen

@@ -2,7 +2,7 @@
2 2
 
3 3
 import uuid from 'uuid';
4 4
 
5
-import { SET_BILLING_ID } from './actionTypes';
5
+import { SET_BILLING_ID, SET_ENDPOINT_COUNTED } from './actionTypes';
6 6
 import { extractVpaasTenantFromPath, getBillingId, sendCountRequest } from './functions';
7 7
 
8 8
 /**
@@ -33,6 +33,7 @@ export function countEndpoint() {
33 33
                 jwt,
34 34
                 tenant
35 35
             });
36
+            dispatch(setEndpointCounted());
36 37
         }
37 38
     };
38 39
 }
@@ -49,3 +50,14 @@ function setBillingId(value) {
49 50
         value
50 51
     };
51 52
 }
53
+
54
+/**
55
+ * Action used to mark the endpoint as counted.
56
+ *
57
+ * @returns {Object}
58
+ */
59
+function setEndpointCounted() {
60
+    return {
61
+        type: SET_ENDPOINT_COUNTED
62
+    };
63
+}

+ 9
- 4
react/features/billing-counter/middleware.js Datei anzeigen

@@ -1,4 +1,4 @@
1
-import { CONFERENCE_JOINED } from '../base/conference/actionTypes';
1
+import { PARTICIPANT_JOINED } from '../base/participants/actionTypes';
2 2
 import { MiddlewareRegistry } from '../base/redux';
3 3
 
4 4
 import { SET_BILLING_ID } from './actionTypes';
@@ -11,6 +11,7 @@ import { setBillingId } from './functions';
11 11
  * @param {Store} store - The redux store.
12 12
  * @returns {Function}
13 13
  */
14
+
14 15
 MiddlewareRegistry.register(store => next => async action => {
15 16
     switch (action.type) {
16 17
     case SET_BILLING_ID: {
@@ -19,12 +20,16 @@ MiddlewareRegistry.register(store => next => async action => {
19 20
         break;
20 21
     }
21 22
 
22
-    case CONFERENCE_JOINED: {
23
-        store.dispatch(countEndpoint());
23
+    case PARTICIPANT_JOINED: {
24
+        const shouldCount = !store.getState()['features/billing-counter'].endpointCounted
25
+              && !action.participant.local;
26
+
27
+        if (shouldCount) {
28
+            store.dispatch(countEndpoint());
29
+        }
24 30
 
25 31
         break;
26 32
     }
27
-
28 33
     }
29 34
 
30 35
     return next(action);

+ 29
- 0
react/features/billing-counter/reducer.js Datei anzeigen

@@ -0,0 +1,29 @@
1
+import { ReducerRegistry } from '../base/redux';
2
+
3
+import {
4
+    SET_ENDPOINT_COUNTED
5
+} from './actionTypes';
6
+
7
+const DEFAULT_STATE = {
8
+    endpointCounted: false
9
+};
10
+
11
+/**
12
+ * Listen for actions that mutate the billing-counter state
13
+ */
14
+ReducerRegistry.register(
15
+    'features/billing-counter', (state = DEFAULT_STATE, action) => {
16
+        switch (action.type) {
17
+
18
+        case SET_ENDPOINT_COUNTED: {
19
+            return {
20
+                ...state,
21
+                endpointCounted: true
22
+            };
23
+        }
24
+
25
+        default:
26
+            return state;
27
+        }
28
+    },
29
+);

Laden…
Abbrechen
Speichern