logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

relationship_serializer.rb (1167B)


  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. def id
  6. object.id.to_s
  7. end
  8. def following
  9. instance_options[:relationships].following[object.id] ? true : false
  10. end
  11. def showing_reblogs
  12. (instance_options[:relationships].following[object.id] || {})[:reblogs] ||
  13. (instance_options[:relationships].requested[object.id] || {})[:reblogs] ||
  14. false
  15. end
  16. def followed_by
  17. instance_options[:relationships].followed_by[object.id] || false
  18. end
  19. def blocking
  20. instance_options[:relationships].blocking[object.id] || false
  21. end
  22. def muting
  23. instance_options[:relationships].muting[object.id] ? true : false
  24. end
  25. def muting_notifications
  26. (instance_options[:relationships].muting[object.id] || {})[:notifications] || false
  27. end
  28. def requested
  29. instance_options[:relationships].requested[object.id] ? true : false
  30. end
  31. def domain_blocking
  32. instance_options[:relationships].domain_blocking[object.id] || false
  33. end
  34. end