feat(Participant): reuse avatar URL generation logic
It was moved to js-utils, so make use of it.
This commit is contained in:
parent
e164a23cf0
commit
057b300074
|
@ -47,6 +47,7 @@
|
||||||
"jquery-contextmenu": "2.4.5",
|
"jquery-contextmenu": "2.4.5",
|
||||||
"jquery-i18next": "1.2.0",
|
"jquery-i18next": "1.2.0",
|
||||||
"js-md5": "0.6.1",
|
"js-md5": "0.6.1",
|
||||||
|
"js-utils": "github:jitsi/js-utils#446497893023aa8dec403e0e4e35a22cae6bc87d",
|
||||||
"jsc-android": "224109.1.0",
|
"jsc-android": "224109.1.0",
|
||||||
"jsrsasign": "8.0.12",
|
"jsrsasign": "8.0.12",
|
||||||
"jwt-decode": "2.2.0",
|
"jwt-decode": "2.2.0",
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// @flow
|
// @flow
|
||||||
import md5 from 'js-md5';
|
import { getAvatarURL as _getAvatarURL } from 'js-utils/avatar';
|
||||||
|
|
||||||
import { toState } from '../redux';
|
import { toState } from '../redux';
|
||||||
|
|
||||||
|
@ -42,40 +42,18 @@ export function getAvatarURL({ avatarID, avatarURL, email, id }: {
|
||||||
return avatarURL;
|
return avatarURL;
|
||||||
}
|
}
|
||||||
|
|
||||||
let key = email || avatarID;
|
// The deployment is allowed to choose the avatar service which is to
|
||||||
let urlPrefix;
|
// generate the random avatars.
|
||||||
let urlSuffix;
|
const avatarService
|
||||||
|
= typeof interfaceConfig === 'object'
|
||||||
|
&& interfaceConfig.RANDOM_AVATAR_URL_PREFIX
|
||||||
|
? {
|
||||||
|
urlPrefix: interfaceConfig.RANDOM_AVATAR_URL_PREFIX,
|
||||||
|
urlSuffix: interfaceConfig.RANDOM_AVATAR_URL_SUFFIX }
|
||||||
|
: undefined;
|
||||||
|
|
||||||
// If the ID looks like an e-mail address, we'll use Gravatar because it
|
// eslint-disable-next-line object-property-newline
|
||||||
// supports e-mail addresses.
|
return _getAvatarURL({ avatarID, email, id }, avatarService);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -15,8 +15,6 @@ const minimize
|
||||||
= process.argv.indexOf('-p') !== -1
|
= process.argv.indexOf('-p') !== -1
|
||||||
|| process.argv.indexOf('--optimize-minimize') !== -1;
|
|| process.argv.indexOf('--optimize-minimize') !== -1;
|
||||||
|
|
||||||
// eslint-disable-next-line camelcase
|
|
||||||
const node_modules = `${__dirname}/node_modules/`;
|
|
||||||
const plugins = [
|
const plugins = [
|
||||||
new webpack.LoaderOptionsPlugin({
|
new webpack.LoaderOptionsPlugin({
|
||||||
debug: !minimize,
|
debug: !minimize,
|
||||||
|
@ -62,7 +60,9 @@ const config = {
|
||||||
// Transpile ES2015 (aka ES6) to ES5. Accept the JSX syntax by React
|
// Transpile ES2015 (aka ES6) to ES5. Accept the JSX syntax by React
|
||||||
// as well.
|
// as well.
|
||||||
|
|
||||||
exclude: node_modules, // eslint-disable-line camelcase
|
exclude: [
|
||||||
|
new RegExp(`${__dirname}/node_modules/(?!js-utils)`)
|
||||||
|
],
|
||||||
loader: 'babel-loader',
|
loader: 'babel-loader',
|
||||||
options: {
|
options: {
|
||||||
// XXX The require.resolve bellow solves failures to locate the
|
// XXX The require.resolve bellow solves failures to locate the
|
||||||
|
|
Loading…
Reference in New Issue