parent
b395b50398
commit
bf30d36682
@ -1,40 +1,19 @@ |
|||||||
import { Session } from 'meteor/session'; |
import { Session } from 'meteor/session'; |
||||||
import { Meteor } from 'meteor/meteor'; |
|
||||||
import { Tracker } from 'meteor/tracker'; |
import { Tracker } from 'meteor/tracker'; |
||||||
|
|
||||||
import { getAvatarURL } from './getAvatarURL'; |
import { getAvatarURL } from './getAvatarURL'; |
||||||
import { settings } from '../../settings'; |
import { settings } from '../../settings'; |
||||||
|
|
||||||
let externalSource = ''; |
export const getUserAvatarURL = function(username) { |
||||||
|
const externalSource = (settings.get('Accounts_AvatarExternalProviderUrl') || '').trim().replace(/\/$/, ''); |
||||||
if (Meteor.isServer) { |
if (externalSource !== '') { |
||||||
settings.get('Accounts_AvatarExternalProviderUrl', (key, value = '') => { |
return externalSource.replace('{username}', username); |
||||||
externalSource = value.trim().replace(/\/$/, ''); |
|
||||||
}); |
|
||||||
} else { |
|
||||||
Tracker.autorun(function() { |
|
||||||
externalSource = (settings.get('Accounts_AvatarExternalProviderUrl') || '').trim().replace(/\/$/, ''); |
|
||||||
}); |
|
||||||
} |
|
||||||
|
|
||||||
export const getUserAvatarURL = Meteor.isServer |
|
||||||
? function(username) { |
|
||||||
if (username == null) { |
|
||||||
return; |
|
||||||
} |
|
||||||
if (externalSource !== '') { |
|
||||||
return externalSource.replace('{username}', username); |
|
||||||
} |
|
||||||
return getAvatarURL({ username }); |
|
||||||
} |
} |
||||||
: function(username) { |
if (username == null) { |
||||||
if (username == null) { |
return; |
||||||
return; |
} |
||||||
} |
const key = `avatar_random_${ username }`; |
||||||
if (externalSource !== '') { |
const cache = Tracker.nonreactive(() => Session && Session.get(key)); // there is no Session on server
|
||||||
return externalSource.replace('{username}', username); |
|
||||||
} |
return getAvatarURL({ username, cache }); |
||||||
const key = `avatar_random_${ username }`; |
}; |
||||||
const cache = Tracker.nonreactive(() => Session.get(key)); |
|
||||||
return getAvatarURL({ username, cache }); |
|
||||||
}; |
|
||||||
|
Loading…
Reference in new issue