orbitalimpact / hipmost

Migrate your Hipchat history to Mattermost
MIT License
10 stars 5 forks source link

NoMethod error caused by nil users #10

Open davidbartonau opened 6 years ago

davidbartonau commented 6 years ago

I believe pull request #5 is causing errors. I ran through the change log and that was the commit that caused this error @heuri

I'm not a ruby programmer, but I will attempt to fix it :-/

Traceback (most recent call last):
    11: from /home/sandbox/.gem/ruby/2.5.0/bin/hipmost:23:in `<main>'
    10: from /home/sandbox/.gem/ruby/2.5.0/bin/hipmost:23:in `load'
     9: from /home/sandbox/.gem/ruby/2.5.0/gems/hipmost-1.0/exe/hipmost:48:in `<top (required)>'
     8: from /home/sandbox/.gem/ruby/2.5.0/gems/hipmost-1.0/lib/hipmost.rb:14:in `run'
     7: from /home/sandbox/.gem/ruby/2.5.0/gems/hipmost-1.0/lib/hipmost/cmds/room.rb:23:in `run'
     6: from /home/sandbox/.gem/ruby/2.5.0/gems/hipmost-1.0/lib/hipmost/cmds/room.rb:47:in `import'
     5: from /home/sandbox/.gem/ruby/2.5.0/gems/hipmost-1.0/lib/hipmost/cmds/room.rb:54:in `save'
     4: from /home/sandbox/.gem/ruby/2.5.0/gems/hipmost-1.0/lib/hipmost/cmds/room.rb:54:in `open'
     3: from /home/sandbox/.gem/ruby/2.5.0/gems/hipmost-1.0/lib/hipmost/cmds/room.rb:64:in `block in save'
     2: from /home/sandbox/.gem/ruby/2.5.0/gems/hipmost-1.0/lib/hipmost/cmds/room.rb:64:in `each'
     1: from /home/sandbox/.gem/ruby/2.5.0/gems/hipmost-1.0/lib/hipmost/cmds/room.rb:65:in `block (2 levels) in save'
/home/sandbox/.gem/ruby/2.5.0/gems/hipmost-1.0/lib/hipmost/hipchat/room.rb:46:in `users': undefined method `[]' for nil:NilClass (NoMethodError)
        if not attrs["members"].first.is_a? Integer
          @users ||= [ Hipchat.users[attrs["members"].first["id"]] ]  # <-------
        else
          @users ||= attrs["members"].map{|uid| Hipchat.users[uid] }
        end
davidbartonau commented 6 years ago

@heuri I put in a fix that works for me in my fork, but I may have broken your case.