Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

feat(Participant): reuse avatar URL generation logic

Saúl Ibarra Corretgé057b3000740a
diff --git a/package.json b/package.json
index 9e7f26cb16..6211b15416 100644
--- a/package.json
+++ b/package.json
@@ -47,6 +47,7 @@
"jquery-contextmenu": "2.4.5",
"jquery-i18next": "1.2.0",
"js-md5": "0.6.1",
+ "js-utils": "github:jitsi/js-utils#446497893023aa8dec403e0e4e35a22cae6bc87d",
"jsc-android": "224109.1.0",
"jsrsasign": "8.0.12",
"jwt-decode": "2.2.0",
diff --git a/react/features/base/participants/functions.js b/react/features/base/participants/functions.js
index ea24a6890b..e2f4d69709 100644
--- a/react/features/base/participants/functions.js
+++ b/react/features/base/participants/functions.js
@@ -1,5 +1,5 @@
// @flow
-import md5 from 'js-md5';
+import { getAvatarURL as _getAvatarURL } from 'js-utils/avatar';
import { toState } from '../redux';
@@ -42,40 +42,18 @@ export function getAvatarURL({ avatarID, avatarURL, email, id }: {
return avatarURL;
}
- let key = email || avatarID;
- let urlPrefix;
- let urlSuffix;
-
- // If the ID looks like an e-mail address, we'll use Gravatar because it
- // supports e-mail addresses.
- if (key && key.indexOf('@') > 0) {
- urlPrefix = 'https://www.gravatar.com/avatar/';
- urlSuffix = '?d=wavatar&size=200';
- } else {
- // Otherwise, we do not have much a choice but a random avatar (fetched
- // from a configured avatar service).
- if (!key) {
- key = id;
- if (!key) {
- return undefined;
- }
- }
-
- // The deployment is allowed to choose the avatar service which is to
- // generate the random avatars.
- urlPrefix
- = typeof interfaceConfig === 'object'
- && interfaceConfig.RANDOM_AVATAR_URL_PREFIX;
- if (urlPrefix) {
- urlSuffix = interfaceConfig.RANDOM_AVATAR_URL_SUFFIX;
- } else {
- // Otherwise, use a default (meeples, of course).
- urlPrefix = 'https://abotars.jitsi.net/meeple/';
- urlSuffix = '';
- }
- }
-
- return urlPrefix + md5.hex(key.trim().toLowerCase()) + urlSuffix;
+ // The deployment is allowed to choose the avatar service which is to
+ // generate the random avatars.
+ const avatarService
+ = typeof interfaceConfig === 'object'
+ && interfaceConfig.RANDOM_AVATAR_URL_PREFIX
+ ? {
+ urlPrefix: interfaceConfig.RANDOM_AVATAR_URL_PREFIX,
+ urlSuffix: interfaceConfig.RANDOM_AVATAR_URL_SUFFIX }
+ : undefined;
+
+ // eslint-disable-next-line object-property-newline
+ return _getAvatarURL({ avatarID, email, id }, avatarService);
}
/**
diff --git a/webpack.config.js b/webpack.config.js
index 0f05a1c0f6..dd19718b7f 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -15,8 +15,6 @@ const minimize
= process.argv.indexOf('-p') !== -1
|| process.argv.indexOf('--optimize-minimize') !== -1;
-// eslint-disable-next-line camelcase
-const node_modules = `${__dirname}/node_modules/`;
const plugins = [
new webpack.LoaderOptionsPlugin({
debug: !minimize,
@@ -62,7 +60,9 @@ const config = {
// Transpile ES2015 (aka ES6) to ES5. Accept the JSX syntax by React
// as well.
- exclude: node_modules, // eslint-disable-line camelcase
+ exclude: [
+ new RegExp(`${__dirname}/node_modules/(?!js-utils)`)
+ ],
loader: 'babel-loader',
options: {
// XXX The require.resolve bellow solves failures to locate the