Browse Source

feat(avatar) add ability to customize Gravatar base URL

Also, default to libravatar.

Closes: https://github.com/jitsi/jitsi-meet/issues/4927
j8
Saúl Ibarra Corretgé 4 years ago
parent
commit
a7de8be0aa

+ 3
- 0
config.js View File

393
     // Document should be focused for this option to work
393
     // Document should be focused for this option to work
394
     // enableAutomaticUrlCopy: false,
394
     // enableAutomaticUrlCopy: false,
395
 
395
 
396
+    // Base URL for a Gravatar-compatible service. Defaults to libravatar.
397
+    // gravatarBaseURL: 'https://seccdn.libravatar.org/avatar/';
398
+
396
     // Stats
399
     // Stats
397
     //
400
     //
398
 
401
 

+ 17
- 3
package-lock.json View File

3302
       }
3302
       }
3303
     },
3303
     },
3304
     "@jitsi/js-utils": {
3304
     "@jitsi/js-utils": {
3305
-      "version": "1.0.2",
3306
-      "resolved": "https://registry.npmjs.org/@jitsi/js-utils/-/js-utils-1.0.2.tgz",
3307
-      "integrity": "sha512-ls+X9tn9EemUQwPEBr7Z0UD4sjRtwcu1Bh4MUo0Hv4arp0KVzcCYCW+mofsvuZvHg8xJX12LLNVgUKi1X5XTGg==",
3305
+      "version": "1.0.3",
3306
+      "resolved": "https://registry.npmjs.org/@jitsi/js-utils/-/js-utils-1.0.3.tgz",
3307
+      "integrity": "sha512-m6mZz7R716mHP21lTKQffyM0nNFu3Fe/EHCaOVLFY/vdPsaUl9DhypJqtPIYzRUfPnmnugdaxcxrUeSZQXQzVA==",
3308
       "requires": {
3308
       "requires": {
3309
         "bowser": "2.7.0",
3309
         "bowser": "2.7.0",
3310
         "js-md5": "0.7.3"
3310
         "js-md5": "0.7.3"
10792
         "webrtc-adapter": "7.5.0"
10792
         "webrtc-adapter": "7.5.0"
10793
       },
10793
       },
10794
       "dependencies": {
10794
       "dependencies": {
10795
+        "@jitsi/js-utils": {
10796
+          "version": "1.0.2",
10797
+          "resolved": "https://registry.npmjs.org/@jitsi/js-utils/-/js-utils-1.0.2.tgz",
10798
+          "integrity": "sha512-ls+X9tn9EemUQwPEBr7Z0UD4sjRtwcu1Bh4MUo0Hv4arp0KVzcCYCW+mofsvuZvHg8xJX12LLNVgUKi1X5XTGg==",
10799
+          "requires": {
10800
+            "bowser": "2.7.0",
10801
+            "js-md5": "0.7.3"
10802
+          }
10803
+        },
10804
+        "js-md5": {
10805
+          "version": "0.7.3",
10806
+          "resolved": "https://registry.npmjs.org/js-md5/-/js-md5-0.7.3.tgz",
10807
+          "integrity": "sha512-ZC41vPSTLKGwIRjqDh8DfXoCrdQIyBgspJVPXHBGu4nZlAEvG3nf+jO9avM9RmLiGakg7vz974ms99nEV0tmTQ=="
10808
+        },
10795
         "uuid": {
10809
         "uuid": {
10796
           "version": "8.1.0",
10810
           "version": "8.1.0",
10797
           "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.1.0.tgz",
10811
           "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.1.0.tgz",

+ 1
- 1
package.json View File

32
     "@atlaskit/theme": "7.0.2",
32
     "@atlaskit/theme": "7.0.2",
33
     "@atlaskit/toggle": "5.0.14",
33
     "@atlaskit/toggle": "5.0.14",
34
     "@atlaskit/tooltip": "12.1.13",
34
     "@atlaskit/tooltip": "12.1.13",
35
-    "@jitsi/js-utils": "1.0.2",
35
+    "@jitsi/js-utils": "1.0.3",
36
     "@microsoft/microsoft-graph-client": "1.1.0",
36
     "@microsoft/microsoft-graph-client": "1.1.0",
37
     "@react-native-community/async-storage": "1.3.4",
37
     "@react-native-community/async-storage": "1.3.4",
38
     "@react-native-community/google-signin": "3.0.1",
38
     "@react-native-community/google-signin": "3.0.1",

+ 17
- 10
react/features/base/participants/functions.js View File

1
 // @flow
1
 // @flow
2
 
2
 
3
 import { getGravatarURL } from '@jitsi/js-utils/avatar';
3
 import { getGravatarURL } from '@jitsi/js-utils/avatar';
4
+import type { Store } from 'redux';
4
 
5
 
5
 import { JitsiParticipantConnectionStatus } from '../lib-jitsi-meet';
6
 import { JitsiParticipantConnectionStatus } from '../lib-jitsi-meet';
6
 import { MEDIA_TYPE, shouldRenderVideoTrack } from '../media';
7
 import { MEDIA_TYPE, shouldRenderVideoTrack } from '../media';
23
  */
24
  */
24
 const AVATAR_QUEUE = [];
25
 const AVATAR_QUEUE = [];
25
 const AVATAR_CHECKED_URLS = new Map();
26
 const AVATAR_CHECKED_URLS = new Map();
26
-/* eslint-disable arrow-body-style */
27
+/* eslint-disable arrow-body-style, no-unused-vars */
27
 const AVATAR_CHECKER_FUNCTIONS = [
28
 const AVATAR_CHECKER_FUNCTIONS = [
28
-    participant => {
29
+    (participant, _) => {
29
         return participant && participant.isJigasi ? JIGASI_PARTICIPANT_ICON : null;
30
         return participant && participant.isJigasi ? JIGASI_PARTICIPANT_ICON : null;
30
     },
31
     },
31
-    participant => {
32
+    (participant, _) => {
32
         return participant && participant.avatarURL ? participant.avatarURL : null;
33
         return participant && participant.avatarURL ? participant.avatarURL : null;
33
     },
34
     },
34
-    participant => {
35
-        return participant && participant.email ? getGravatarURL(participant.email) : null;
35
+    (participant, store) => {
36
+        if (participant && participant.email) {
37
+            return getGravatarURL(participant.email, store.getState()['features/base/config'].gravatarBaseURL);
38
+        }
39
+
40
+        return null;
36
     }
41
     }
37
 ];
42
 ];
38
-/* eslint-enable arrow-body-style */
43
+/* eslint-enable arrow-body-style, no-unused-vars */
39
 
44
 
40
 /**
45
 /**
41
  * Resolves the first loadable avatar URL for a participant.
46
  * Resolves the first loadable avatar URL for a participant.
42
  *
47
  *
43
  * @param {Object} participant - The participant to resolve avatars for.
48
  * @param {Object} participant - The participant to resolve avatars for.
49
+ * @param {Store} store - Redux store.
44
  * @returns {Promise}
50
  * @returns {Promise}
45
  */
51
  */
46
-export function getFirstLoadableAvatarUrl(participant: Object) {
52
+export function getFirstLoadableAvatarUrl(participant: Object, store: Store<any, any>) {
47
     const deferred = createDeferred();
53
     const deferred = createDeferred();
48
     const fullPromise = deferred.promise
54
     const fullPromise = deferred.promise
49
-        .then(() => _getFirstLoadableAvatarUrl(participant))
55
+        .then(() => _getFirstLoadableAvatarUrl(participant, store))
50
         .then(src => {
56
         .then(src => {
51
 
57
 
52
             if (AVATAR_QUEUE.length) {
58
             if (AVATAR_QUEUE.length) {
402
  * Resolves the first loadable avatar URL for a participant.
408
  * Resolves the first loadable avatar URL for a participant.
403
  *
409
  *
404
  * @param {Object} participant - The participant to resolve avatars for.
410
  * @param {Object} participant - The participant to resolve avatars for.
411
+ * @param {Store} store - Redux store.
405
  * @returns {?string}
412
  * @returns {?string}
406
  */
413
  */
407
-async function _getFirstLoadableAvatarUrl(participant) {
414
+async function _getFirstLoadableAvatarUrl(participant, store) {
408
     for (let i = 0; i < AVATAR_CHECKER_FUNCTIONS.length; i++) {
415
     for (let i = 0; i < AVATAR_CHECKER_FUNCTIONS.length; i++) {
409
-        const url = AVATAR_CHECKER_FUNCTIONS[i](participant);
416
+        const url = AVATAR_CHECKER_FUNCTIONS[i](participant, store);
410
 
417
 
411
         if (url) {
418
         if (url) {
412
             if (AVATAR_CHECKED_URLS.has(url)) {
419
             if (AVATAR_CHECKED_URLS.has(url)) {

+ 3
- 2
react/features/base/participants/middleware.js View File

365
  * @private
365
  * @private
366
  * @returns {Object} The value returned by {@code next(action)}.
366
  * @returns {Object} The value returned by {@code next(action)}.
367
  */
367
  */
368
-function _participantJoinedOrUpdated({ dispatch, getState }, next, action) {
368
+function _participantJoinedOrUpdated(store, next, action) {
369
+    const { dispatch, getState } = store;
369
     const { participant: { avatarURL, e2eeEnabled, email, id, local, name, raisedHand } } = action;
370
     const { participant: { avatarURL, e2eeEnabled, email, id, local, name, raisedHand } } = action;
370
 
371
 
371
     // Send an external update of the local participant's raised hand state
372
     // Send an external update of the local participant's raised hand state
401
         const participantId = !id && local ? getLocalParticipant(getState()).id : id;
402
         const participantId = !id && local ? getLocalParticipant(getState()).id : id;
402
         const updatedParticipant = getParticipantById(getState(), participantId);
403
         const updatedParticipant = getParticipantById(getState(), participantId);
403
 
404
 
404
-        getFirstLoadableAvatarUrl(updatedParticipant)
405
+        getFirstLoadableAvatarUrl(updatedParticipant, store)
405
             .then(url => {
406
             .then(url => {
406
                 dispatch(setLoadableAvatarUrl(participantId, url));
407
                 dispatch(setLoadableAvatarUrl(participantId, url));
407
             });
408
             });

+ 3
- 2
react/features/lobby/middleware.js View File

144
  * @param {Object} participant - The knocking participant.
144
  * @param {Object} participant - The knocking participant.
145
  * @returns {void}
145
  * @returns {void}
146
  */
146
  */
147
-function _findLoadableAvatarForKnockingParticipant({ dispatch, getState }, { id }) {
147
+function _findLoadableAvatarForKnockingParticipant(store, { id }) {
148
+    const { dispatch, getState } = store;
148
     const updatedParticipant = getState()['features/lobby'].knockingParticipants.find(p => p.id === id);
149
     const updatedParticipant = getState()['features/lobby'].knockingParticipants.find(p => p.id === id);
149
     const { disableThirdPartyRequests } = getState()['features/base/config'];
150
     const { disableThirdPartyRequests } = getState()['features/base/config'];
150
 
151
 
151
     if (!disableThirdPartyRequests && updatedParticipant && !updatedParticipant.loadableAvatarUrl) {
152
     if (!disableThirdPartyRequests && updatedParticipant && !updatedParticipant.loadableAvatarUrl) {
152
-        getFirstLoadableAvatarUrl(updatedParticipant).then(loadableAvatarUrl => {
153
+        getFirstLoadableAvatarUrl(updatedParticipant, store).then(loadableAvatarUrl => {
153
             if (loadableAvatarUrl) {
154
             if (loadableAvatarUrl) {
154
                 dispatch(participantIsKnockingOrUpdated({
155
                 dispatch(participantIsKnockingOrUpdated({
155
                     loadableAvatarUrl,
156
                     loadableAvatarUrl,

Loading…
Cancel
Save