Skip to content

Commit

Permalink
Fix crash on formatting plaintext history
Browse files Browse the repository at this point in the history
  • Loading branch information
karlicoss committed Apr 8, 2017
1 parent 9797581 commit 28e433e
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions formatters/plaintext.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ def format_message(dialog, message, output_stream)

line = case message['event'].downcase
when 'message'
fwd_from_name = get_full_name(message['fwd_from'])
if !fwd_from_name.empty?
from_name += ' (forwarded from %s)' % fwd_from_name
if message['fwd_from']
fwd_from_name = get_full_name(message['fwd_from'])
if !fwd_from_name.empty?
from_name += ' (forwarded from %s)' % fwd_from_name
end
elsif message['reply_id']
reply_target = find_earlier_message(message['reply_id'])
if reply_target
Expand Down Expand Up @@ -49,10 +51,10 @@ def format_message(dialog, message, output_stream)
end

when 'service'
user = message['action']['user']
user_name = get_full_name(user)
case message['action']['type'].downcase
when 'chat_add_user'
user = message['action']['user']
user_name = get_full_name(user)
if message['from']['peer_id'] == user['peer_id'] ||
!message['from']['peer_id']
"#{user_name} joined"
Expand All @@ -62,6 +64,8 @@ def format_message(dialog, message, output_stream)
when 'chat_add_user_link'
"#{from_name} joined with an invite link"
when 'chat_del_user'
user = message['action']['user']
user_name = get_full_name(user)
if message['from']['peer_id'] == user['peer_id'] ||
!message['from']['peer_id']
"#{user_name} left"
Expand Down

0 comments on commit 28e433e

Please sign in to comment.