peoplegroup-connectors 0.1.93 → 0.1.96
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/peoplegroup/connectors/bamboo.rb +2 -16
- data/lib/peoplegroup/connectors/slack.rb +37 -17
- data/lib/peoplegroup/connectors/version.rb +1 -1
- metadata +4 -5
- data/data/email_mapper.yml +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8bf603701e7dc27da76fcc61f2a8a4047133e7933ea58ec0f2549efb1d709afe
|
4
|
+
data.tar.gz: 8e600b62d801d284c831fb69fd55430d9322594b355ce5a65fe1cca335c387ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: abd0763536f8eeeb9769e8ee5c2996e27ea459194613ab3e8bb6db249feb9620fc0a283f01e791adb9ecb04638775dd75ff33a37fbc7a957dfd38dff5d449a76
|
7
|
+
data.tar.gz: 07d010c5b8c01fbcfa8e2bc84e741280034974ce4e7499027f488c2af4ea0b190bfbffe55a61073a6db3a673d24a5a23c41a4209ed4cac708821c732fe74e174
|
@@ -67,6 +67,7 @@ module PeopleGroup
|
|
67
67
|
def search_team_member_by_email(email)
|
68
68
|
team_members.find { |team_member| team_member['workEmail']&.downcase == email&.downcase }
|
69
69
|
end
|
70
|
+
alias_method :slack_email_lookup_with_fallback, :search_team_member_by_email
|
70
71
|
|
71
72
|
def search_team_member_by_email!(email)
|
72
73
|
team_member = search_team_member_by_email(email)
|
@@ -74,22 +75,7 @@ module PeopleGroup
|
|
74
75
|
|
75
76
|
team_member
|
76
77
|
end
|
77
|
-
|
78
|
-
def slack_email_lookup_with_fallback(email)
|
79
|
-
file_path = File.join(__dir__, '../../../data/email_mapper.yml')
|
80
|
-
email_mapper = YAML.load_file(file_path)
|
81
|
-
email_hit = email_mapper.find { |mapping| mapping['slack_email'] == email.delete_suffix('@gitlab.com') }
|
82
|
-
email = "#{email_hit['bamboo_email']}@gitlab.com" if email_hit
|
83
|
-
|
84
|
-
employees.find { |employee| employee['workEmail'] == email }
|
85
|
-
end
|
86
|
-
|
87
|
-
def slack_email_lookup_with_fallback!(email)
|
88
|
-
employee = slack_email_lookup_with_fallback(email)
|
89
|
-
raise EmployeeNotFoundError, "No employee found with Slack email #{email}" if employee.nil?
|
90
|
-
|
91
|
-
employee
|
92
|
-
end
|
78
|
+
alias_method :slack_email_lookup_with_fallback!, :search_team_member_by_email!
|
93
79
|
|
94
80
|
def team_members_by_department(department)
|
95
81
|
active_and_current_team_members.select { |team_member| team_member['department'] == department }
|
@@ -12,22 +12,13 @@ module PeopleGroup
|
|
12
12
|
@client = ::Slack::Web::Client.new
|
13
13
|
end
|
14
14
|
|
15
|
-
def
|
16
|
-
@client.users_lookupByEmail(email: email)
|
17
|
-
rescue ::Slack::Web::Api::Errors::SlackError
|
18
|
-
nil
|
19
|
-
end
|
20
|
-
|
21
|
-
def bamboo_email_lookup_with_fallback(email)
|
22
|
-
file_path = File.join(__dir__, '../../../data/email_mapper.yml')
|
23
|
-
email_mapper = YAML.load_file(file_path)
|
24
|
-
email_hit = email_mapper.find { |mapping| mapping['bamboo_email'] == email.delete_suffix('@gitlab.com') }
|
25
|
-
email = "#{email_hit['slack_email']}@gitlab.com" if email_hit
|
26
|
-
|
15
|
+
def bamboo_email_lookup(email)
|
27
16
|
@client.users_lookupByEmail(email: email)
|
28
17
|
rescue ::Slack::Web::Api::Errors::SlackError
|
29
18
|
nil
|
30
19
|
end
|
20
|
+
alias_method :bamboo_email_lookup_with_fallback, :bamboo_email_lookup
|
21
|
+
alias_method :find_user, :bamboo_email_lookup
|
31
22
|
|
32
23
|
def find_user_by_id(id)
|
33
24
|
@client.users_info(user: id)
|
@@ -41,33 +32,62 @@ module PeopleGroup
|
|
41
32
|
nil
|
42
33
|
end
|
43
34
|
|
35
|
+
# https://www.rubydoc.info/gems/slack-ruby-client/0.17.0/Slack%2FWeb%2FApi%2FEndpoints%2FConversations:conversations_list
|
36
|
+
# Defaults to only show public channels.
|
44
37
|
def list_public_channels
|
45
|
-
|
46
|
-
channels.
|
38
|
+
response = @client.conversations_list(exclude_archived: true)
|
39
|
+
response['channels'].map { |channel| channel['name'] }
|
47
40
|
end
|
48
41
|
|
42
|
+
# https://www.rubydoc.info/gems/slack-ruby-client/0.17.0/Slack%2FWeb%2FApi%2FEndpoints%2FChat:chat_getPermalink
|
49
43
|
def link_for_message(channel:, timestamp:)
|
50
44
|
@client.chat_getPermalink(channel: channel, message_ts: timestamp)
|
51
45
|
end
|
52
46
|
|
47
|
+
# https://www.rubydoc.info/gems/slack-ruby-client/0.17.0/Slack%2FWeb%2FApi%2FEndpoints%2FChat:chat_postMessage
|
53
48
|
def send_message(channel:, text: '', as_user: true, attachments: [], thread_ts: nil, reply_broadcast: false, formatted_message: [])
|
54
|
-
|
49
|
+
options = {
|
50
|
+
channel: channel,
|
51
|
+
text: text,
|
52
|
+
as_user: true,
|
53
|
+
attachments: attachments,
|
54
|
+
unfurl_links: false,
|
55
|
+
thread_ts: thread_ts,
|
56
|
+
reply_broadcast: reply_broadcast,
|
57
|
+
blocks: formatted_message
|
58
|
+
}
|
59
|
+
|
60
|
+
@client.chat_postMessage(options)
|
55
61
|
end
|
56
62
|
|
63
|
+
# https://www.rubydoc.info/gems/slack-ruby-client/0.17.0/Slack%2FWeb%2FApi%2FEndpoints%2FChat:chat_update
|
57
64
|
def update_message(channel:, timestamp:, text: '', attachments: [], formatted_message: [])
|
58
|
-
|
65
|
+
options = {
|
66
|
+
channel: channel,
|
67
|
+
text: text,
|
68
|
+
ts: timestamp,
|
69
|
+
as_user: true,
|
70
|
+
attachments: attachments,
|
71
|
+
blocks: formatted_message
|
72
|
+
}
|
73
|
+
|
74
|
+
@client.chat_update(options)
|
59
75
|
end
|
60
76
|
|
77
|
+
# https://www.rubydoc.info/gems/slack-ruby-client/0.17.0/Slack%2FWeb%2FApi%2FEndpoints%2FViews:views_open
|
61
78
|
def send_modal_message(trigger:, view:)
|
62
79
|
@client.views_open(trigger_id: trigger, view: view)
|
63
80
|
end
|
64
81
|
|
82
|
+
# https://www.rubydoc.info/gems/slack-ruby-client/0.17.0/Slack%2FWeb%2FApi%2FEndpoints%2FViews:views_publish
|
65
83
|
def publish_view(user_id:, trigger:, view:)
|
66
84
|
@client.views_publish(user_id: user_id, trigger_id: trigger, view: view)
|
67
85
|
end
|
68
86
|
|
87
|
+
# https://www.rubydoc.info/gems/slack-ruby-client/0.17.0/Slack%2FWeb%2FApi%2FEndpoints%2FConversations:conversations_history
|
69
88
|
def get_message(channel:, timestamp:)
|
70
|
-
|
89
|
+
options = { channel: channel, latest: timestamp, limit: 1, inclusive: true }
|
90
|
+
@client.conversations_history(options)&.messages&.first
|
71
91
|
end
|
72
92
|
end
|
73
93
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: peoplegroup-connectors
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.96
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- lien van den steen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-03-
|
11
|
+
date: 2022-03-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gitlab
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '0
|
47
|
+
version: '1.0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '0
|
54
|
+
version: '1.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: splinter-pto
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -229,7 +229,6 @@ extra_rdoc_files: []
|
|
229
229
|
files:
|
230
230
|
- LICENSE.txt
|
231
231
|
- README.md
|
232
|
-
- data/email_mapper.yml
|
233
232
|
- lib/peoplegroup/connectors.rb
|
234
233
|
- lib/peoplegroup/connectors/bamboo.rb
|
235
234
|
- lib/peoplegroup/connectors/gitlab.rb
|