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



10
11
12
13
# File 'lib/self_crypto/group_message.rb', line 10

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

Instance Method Details

#get_message(identity) ⇒ Object



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

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



16
17
18
# File 'lib/self_crypto/group_message.rb', line 16

def to_bytes
  Base64.decode64(value)
end

#to_sString

Returns base64.

Returns:

  • (String)

    base64



21
22
23
# File 'lib/self_crypto/group_message.rb', line 21

def to_s
  @value.dup
end