Skip to content
This repository has been archived by the owner on Jun 30, 2022. It is now read-only.

User email is not being set in SlackUser object #136

Open
cohenaj194 opened this issue Apr 9, 2019 · 2 comments
Open

User email is not being set in SlackUser object #136

cohenaj194 opened this issue Apr 9, 2019 · 2 comments

Comments

@cohenaj194
Copy link

cohenaj194 commented Apr 9, 2019

I noticed that emails were not being passed into the response object. I think the issue lies within the SlackUser object:

https://github.com/litaio/lita-slack/blob/master/lib/lita/adapters/slack/slack_user.rb#L39

Currently this function:

        def initialize(id, name, real_name, metadata)
          @id = id
          @name = name
          @real_name = real_name.to_s
          @email = metadata['email'].to_s
          @metadata = metadata
        end

Is unable to set the @email because the email value is stored under metadata['profile']['email'] not metadata['email']. This fix resolved the issue:

        def initialize(id, name, real_name, metadata)
          @id = id
          @name = name
          @real_name = real_name.to_s
          @email = metadata.dig('profile', 'email').to_s
          @metadata = metadata
        end
@cohenaj194
Copy link
Author

It looks like the fix was included in this PR https://github.com/litaio/lita-slack/pull/113/files#diff-1130de5fc9e0accf9fb732c24f426e40

@llunaplanet
Copy link

llunaplanet commented May 3, 2019

Hey @cohenaj194 I have found a workaround until the PR gets merged, you can leverage the :slack_user_created event to manipulate the object,

on :slack_user_created, :slack_user_created

 def slack_user_created(payload)
    slack_user = payload[:slack_user]
    Lita::User.create(slack_user.id, email: slack_user.metadata["profile"]["email"]) 
end

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants