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.

61 lines
1.0 KiB

  1. # frozen_string_literal: true
  2. class ActivityPub::EncryptedMessageSerializer < ActivityPub::Serializer
  3. context :security
  4. context_extensions :olm
  5. class DeviceSerializer < ActivityPub::Serializer
  6. attributes :type, :device_id
  7. def type
  8. 'Device'
  9. end
  10. def device_id
  11. object
  12. end
  13. end
  14. class DigestSerializer < ActivityPub::Serializer
  15. attributes :type, :digest_algorithm, :digest_value
  16. def type
  17. 'Digest'
  18. end
  19. def digest_algorithm
  20. 'http://www.w3.org/2000/09/xmldsig#hmac-sha256'
  21. end
  22. def digest_value
  23. object
  24. end
  25. end
  26. attributes :type, :message_type, :cipher_text, :message_franking
  27. has_one :attributed_to, serializer: DeviceSerializer
  28. has_one :to, serializer: DeviceSerializer
  29. has_one :digest, serializer: DigestSerializer
  30. def type
  31. 'EncryptedMessage'
  32. end
  33. def attributed_to
  34. object.source_device.device_id
  35. end
  36. def to
  37. object.target_device_id
  38. end
  39. def message_type
  40. object.type
  41. end
  42. def cipher_text
  43. object.body
  44. end
  45. end