Quellcode durchsuchen

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é vor 4 Jahren
Ursprung
Commit
a7de8be0aa

+ 3
- 0
config.js Datei anzeigen

@@ -393,6 +393,9 @@ var config = {
393 393
     // Document should be focused for this option to work
394 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 399
     // Stats
397 400
     //
398 401
 

+ 17
- 3
package-lock.json Datei anzeigen

@@ -3302,9 +3302,9 @@
3302 3302
       }
3303 3303
     },
3304 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 3308
       "requires": {
3309 3309
         "bowser": "2.7.0",
3310 3310
         "js-md5": "0.7.3"
@@ -10792,6 +10792,20 @@
10792 10792
         "webrtc-adapter": "7.5.0"
10793 10793
       },
10794 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 10809
         "uuid": {
10796 10810
           "version": "8.1.0",
10797 10811
           "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.1.0.tgz",

+ 1
- 1
package.json Datei anzeigen

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

+ 17
- 10
react/features/base/participants/functions.js Datei anzeigen

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

+ 3
- 2
react/features/base/participants/middleware.js Datei anzeigen

@@ -365,7 +365,8 @@ function _maybePlaySounds({ getState, dispatch }, action) {
365 365
  * @private
366 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 370
     const { participant: { avatarURL, e2eeEnabled, email, id, local, name, raisedHand } } = action;
370 371
 
371 372
     // Send an external update of the local participant's raised hand state
@@ -401,7 +402,7 @@ function _participantJoinedOrUpdated({ dispatch, getState }, next, action) {
401 402
         const participantId = !id && local ? getLocalParticipant(getState()).id : id;
402 403
         const updatedParticipant = getParticipantById(getState(), participantId);
403 404
 
404
-        getFirstLoadableAvatarUrl(updatedParticipant)
405
+        getFirstLoadableAvatarUrl(updatedParticipant, store)
405 406
             .then(url => {
406 407
                 dispatch(setLoadableAvatarUrl(participantId, url));
407 408
             });

+ 3
- 2
react/features/lobby/middleware.js Datei anzeigen

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

Laden…
Abbrechen
Speichern