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-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",
|
||||
|
|
|
@ -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;
|
||||
// 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;
|
||||
|
||||
// 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;
|
||||
// eslint-disable-next-line object-property-newline
|
||||
return _getAvatarURL({ avatarID, email, id }, avatarService);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue