The code powering m.abunchtell.com https://m.abunchtell.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

50 lines
1.2 KiB

  1. # frozen_string_literal: true
  2. class REST::RelationshipSerializer < ActiveModel::Serializer
  3. attributes :id, :following, :showing_reblogs, :followed_by, :blocking,
  4. :muting, :muting_notifications, :requested, :domain_blocking,
  5. :endorsed
  6. def id
  7. object.id.to_s
  8. end
  9. def following
  10. instance_options[:relationships].following[object.id] ? true : false
  11. end
  12. def showing_reblogs
  13. (instance_options[:relationships].following[object.id] || {})[:reblogs] ||
  14. (instance_options[:relationships].requested[object.id] || {})[:reblogs] ||
  15. false
  16. end
  17. def followed_by
  18. instance_options[:relationships].followed_by[object.id] || false
  19. end
  20. def blocking
  21. instance_options[:relationships].blocking[object.id] || false
  22. end
  23. def muting
  24. instance_options[:relationships].muting[object.id] ? true : false
  25. end
  26. def muting_notifications
  27. (instance_options[:relationships].muting[object.id] || {})[:notifications] || false
  28. end
  29. def requested
  30. instance_options[:relationships].requested[object.id] ? true : false
  31. end
  32. def domain_blocking
  33. instance_options[:relationships].domain_blocking[object.id] || false
  34. end
  35. def endorsed
  36. instance_options[:relationships].endorsed[object.id] || false
  37. end
  38. end