Class: SelfCrypto::GroupMessage

Inherits:
Object
  • Object
show all
Defined in:
lib/self_crypto/group_message.rb

Instance Method Summary collapse

Constructor Details

#initialize(msg) ⇒ GroupMessage

Returns a new instance of GroupMessage.

Parameters:

  • msg (String)

    base64 or bytes



8
9
10
11
# File 'lib/self_crypto/group_message.rb', line 8

def initialize(msg)
  @value = msg
  @data = JSON.parse(msg)
end

Instance Method Details

#get_message(identity) ⇒ Object



23
24
25
26
27
28
29
30
# File 'lib/self_crypto/group_message.rb', line 23

def get_message(identity)
  h = @data['recipients'][identity]
  if h['mtype'] == 0
    PreKeyMessage.new(h['ciphertext'])
  else
    Message.new(h['ciphertext'])
  end
end

#to_bytesString

Returns bytes.

Returns:

  • (String)

    bytes



14
15
16
# File 'lib/self_crypto/group_message.rb', line 14

def to_bytes
  Base64.decode64(value)
end

#to_sString

Returns base64.

Returns:

  • (String)

    base64



19
20
21
# File 'lib/self_crypto/group_message.rb', line 19

def to_s
  @value.dup
end