Commiting
This commit is contained in:
@@ -13,7 +13,7 @@ class REST::GroupSerializer < ActiveModel::Serializer
|
||||
end
|
||||
|
||||
def has_password
|
||||
return !!object.password && object.password.gsub(/\s+/, "").length > 1 && object.password.to_s != "null"
|
||||
object.has_password?
|
||||
end
|
||||
|
||||
def password
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class REST::StatusBookmarkedSerializer < ActiveModel::Serializer
|
||||
attributes :status_id, :account_id, :bookmarked
|
||||
|
||||
def status_id
|
||||
object.id.to_s
|
||||
end
|
||||
|
||||
def account_id
|
||||
current_user.account.id
|
||||
end
|
||||
|
||||
def bookmarked
|
||||
if !current_user.nil?
|
||||
current_user.account.bookmarked?(object)
|
||||
else
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class REST::StatusGroupPinnedSerializer < ActiveModel::Serializer
|
||||
attributes :status_id, :group_id, :pinned_by_group
|
||||
|
||||
def status_id
|
||||
object.id.to_s
|
||||
end
|
||||
|
||||
def group_id
|
||||
instance_options[:group_id]
|
||||
end
|
||||
|
||||
def pinned_by_group
|
||||
if !current_user.nil? || !group_id
|
||||
!GroupPinnedStatus.where(status_id: status_id, group_id: group_id).empty?
|
||||
else
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class REST::StatusPinnedSerializer < ActiveModel::Serializer
|
||||
attributes :status_id, :account_id, :pinned
|
||||
|
||||
def status_id
|
||||
object.id.to_s
|
||||
end
|
||||
|
||||
def account_id
|
||||
current_user.account.id
|
||||
end
|
||||
|
||||
def pinned
|
||||
if !current_user.nil?
|
||||
current_user.account.pinned?(object)
|
||||
else
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
class REST::StatusSerializer < ActiveModel::Serializer
|
||||
attributes :id, :created_at, :revised_at, :in_reply_to_id, :in_reply_to_account_id,
|
||||
:sensitive, :spoiler_text, :visibility, :language,
|
||||
:url, :replies_count, :reblogs_count,
|
||||
:url, :replies_count, :reblogs_count, :pinnable, :pinnable_by_group,
|
||||
:favourites_count, :quote_of_id, :expires_at, :has_quote
|
||||
|
||||
attribute :favourited, if: :current_user?
|
||||
@@ -32,6 +32,7 @@ class REST::StatusSerializer < ActiveModel::Serializer
|
||||
has_one :preloadable_poll, key: :poll, serializer: REST::PollSerializer
|
||||
|
||||
def id
|
||||
# puts "tilly instance:" + instance_options.inspect
|
||||
object.id.to_s
|
||||
end
|
||||
|
||||
@@ -134,22 +135,14 @@ class REST::StatusSerializer < ActiveModel::Serializer
|
||||
end
|
||||
|
||||
def bookmarked
|
||||
if instance_options && instance_options[:relationships]
|
||||
instance_options[:relationships].bookmarks_map[object.id] || false
|
||||
else
|
||||
current_user.account.bookmarked?(object)
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
def pinned
|
||||
if instance_options && instance_options[:relationships]
|
||||
instance_options[:relationships].pins_map[object.id] || false
|
||||
else
|
||||
current_user.account.pinned?(object)
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
def pinnable?
|
||||
def pinnable
|
||||
current_user? &&
|
||||
current_user.account_id == object.account_id &&
|
||||
!object.reblog? &&
|
||||
@@ -157,14 +150,10 @@ class REST::StatusSerializer < ActiveModel::Serializer
|
||||
end
|
||||
|
||||
def pinned_by_group
|
||||
if instance_options && instance_options[:relationships]
|
||||
instance_options[:relationships].group_pins_map[object.id] || false
|
||||
else
|
||||
false
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
def pinnable_by_group?
|
||||
def pinnable_by_group
|
||||
if object.group_id?
|
||||
true
|
||||
else
|
||||
|
||||
@@ -34,6 +34,14 @@ class REST::StatusStatSerializer < ActiveModel::Serializer
|
||||
end
|
||||
end
|
||||
|
||||
def reblogs_count
|
||||
if instance_options && instance_options[:unreblog]
|
||||
object.reblogs_count - 1
|
||||
else
|
||||
object.reblogs_count
|
||||
end
|
||||
end
|
||||
|
||||
def current_user?
|
||||
!current_user.nil?
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user