1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-11 00:08:30 +01:00

Extract gravatar URL fn (#2386)

This commit is contained in:
Mateusz Kwasniewski 2022-11-10 12:13:45 +01:00 committed by GitHub
parent 029bb2453e
commit 076ce027ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 5 deletions

View File

@ -1,5 +1,5 @@
import gravatarUrl from 'gravatar-url';
import Joi from 'joi';
import { generateImageUrl } from '../util/generateImageUrl';
export interface UserData {
id: number;
@ -79,10 +79,7 @@ export default class User implements IUser {
}
generateImageUrl(): string {
return gravatarUrl(this.email || this.username || '' + this.id, {
size: 42,
default: 'retro',
});
return generateImageUrl(this);
}
}

View File

@ -0,0 +1,11 @@
import gravatarUrl from 'gravatar-url';
export const generateImageUrl = (user: {
email: string;
username: string;
id: number;
}): string =>
gravatarUrl(user.email || user.username || String(user.id), {
size: 42,
default: 'retro',
});