2019-12-03 14:10:47 +03:00
|
|
|
import Helper from '@ember/component/helper';
|
2022-02-02 13:38:52 +03:00
|
|
|
import classic from 'ember-classic-decorator';
|
2019-12-03 14:10:47 +03:00
|
|
|
import md5 from 'blueimp-md5';
|
|
|
|
import {isEmpty} from '@ember/utils';
|
|
|
|
import {inject as service} from '@ember/service';
|
|
|
|
|
2022-02-02 13:38:52 +03:00
|
|
|
@classic
|
|
|
|
export default class Gravatar extends Helper {
|
2022-02-03 22:04:43 +03:00
|
|
|
@service config;
|
2019-12-03 14:10:47 +03:00
|
|
|
|
|
|
|
compute([email], {size = 180, d = 'blank'}/*, hash*/) {
|
|
|
|
if (!this.get('config.useGravatar')) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!email || isEmpty(email)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
return `https://www.gravatar.com/avatar/${md5(email)}?s=${size}&d=${d}`;
|
|
|
|
}
|
2022-02-02 13:38:52 +03:00
|
|
|
}
|