2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2025-09-05 08:59:27 +08:00

FIX: default_avatars wasn't being used for some server side templates

This commit is contained in:
Robin Ward 2015-06-26 13:37:50 -04:00
parent 9408d5891d
commit b52e5d1536
4 changed files with 20 additions and 19 deletions

View file

@ -25,15 +25,8 @@ module PrettyText
return "" unless user.present?
# TODO: Add support for ES6 and call `avatar-template` directly
if !user.uploaded_avatar_id && SiteSetting.default_avatars.present?
split_avatars = SiteSetting.default_avatars.split("\n")
if split_avatars.present?
hash = username.each_char.reduce(0) do |result, char|
[((result << 5) - result) + char.ord].pack('L').unpack('l').first
end
avatar_template = split_avatars[hash.abs % split_avatars.size]
end
if !user.uploaded_avatar_id
avatar_template = User.default_template(username)
else
avatar_template = user.avatar_template
end