FEATURE: add support for generic external avatar services

This changes it so we only ship an avatar template down to the client
it has no magic, all it knows is how to plug in size
This commit is contained in:
Sam
2015-09-11 18:14:34 +10:00
committed by Régis Hanol
parent 22688a31ee
commit 6437cd0341
19 changed files with 35 additions and 118 deletions

View File

@@ -4,8 +4,6 @@ class BasicPostSerializer < ApplicationSerializer
:name,
:username,
:avatar_template,
:uploaded_avatar_id,
:letter_avatar_color,
:created_at,
:cooked,
:cooked_hidden
@@ -22,14 +20,6 @@ class BasicPostSerializer < ApplicationSerializer
object.user.try(:avatar_template)
end
def uploaded_avatar_id
object.user.try(:uploaded_avatar_id)
end
def letter_avatar_color
object.user.try(:letter_avatar_color)
end
def cooked_hidden
object.hidden && !scope.is_staff?
end

View File

@@ -1,5 +1,5 @@
class BasicUserSerializer < ApplicationSerializer
attributes :id, :username, :uploaded_avatar_id, :avatar_template, :letter_avatar_color
attributes :id, :username, :avatar_template
def include_name?
SiteSetting.enable_names?
@@ -17,12 +17,4 @@ class BasicUserSerializer < ApplicationSerializer
object[:user] || object
end
def letter_avatar_color
if Hash === object
User.letter_avatar_color(user[:username])
else
user.try(:letter_avatar_color)
end
end
end

View File

@@ -177,9 +177,7 @@ class PostSerializer < BasicPostSerializer
def reply_to_user
{
username: object.reply_to_user.username,
avatar_template: object.reply_to_user.avatar_template,
uploaded_avatar_id: object.reply_to_user.uploaded_avatar_id,
letter_avatar_color: object.reply_to_user.letter_avatar_color,
avatar_template: object.reply_to_user.avatar_template
}
end

View File

@@ -26,12 +26,8 @@ class UserActionSerializer < ApplicationSerializer
:action_code,
:edit_reason,
:category_id,
:uploaded_avatar_id,
:letter_avatar_color,
:closed,
:archived,
:acting_uploaded_avatar_id,
:acting_letter_avatar_color
:archived
def excerpt
cooked = object.cooked || PrettyText.cook(object.raw)
@@ -86,12 +82,4 @@ class UserActionSerializer < ApplicationSerializer
object.topic_archived
end
def letter_avatar_color
User.letter_avatar_color(username)
end
def acting_letter_avatar_color
User.letter_avatar_color(acting_username)
end
end