~cytrogen/masto-fe

ref: 685270f3f7ea6d4a8a48ec641e8fdfd9fc2e2d7f masto-fe/app/serializers/activitypub/device_serializer.rb -rw-r--r-- 928 bytes
685270f3 — Claire [Glitch] Fix clicking “Explore” or “Live feeds” column headers to scroll in advanced mode 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# frozen_string_literal: true

class ActivityPub::DeviceSerializer < ActivityPub::Serializer
  context_extensions :olm

  include RoutingHelper

  class FingerprintKeySerializer < ActivityPub::Serializer
    attributes :type, :public_key_base64

    def type
      'Ed25519Key'
    end

    def public_key_base64
      object.fingerprint_key
    end
  end

  class IdentityKeySerializer < ActivityPub::Serializer
    attributes :type, :public_key_base64

    def type
      'Curve25519Key'
    end

    def public_key_base64
      object.identity_key
    end
  end

  attributes :device_id, :type, :name, :claim

  has_one :fingerprint_key, serializer: FingerprintKeySerializer
  has_one :identity_key, serializer: IdentityKeySerializer

  def type
    'Device'
  end

  def claim
    account_claim_url(object.account, id: object.device_id)
  end

  def fingerprint_key
    object
  end

  def identity_key
    object
  end
end