Module: Legion::Extensions::MicrosoftTeams::Runners::Presence
- Includes:
- Helpers::Lex, Helpers::Client
- Included in:
- Client
- Defined in:
- lib/legion/extensions/microsoft_teams/runners/presence.rb
Class Method Summary
collapse
Instance Method Summary
collapse
#bot_connection, #graph_connection, #oauth_connection, #user_path
Class Method Details
.trigger_words ⇒ Object
12
13
14
|
# File 'lib/legion/extensions/microsoft_teams/runners/presence.rb', line 12
def self.trigger_words
%w[presence availability available status online busy away]
end
|
Instance Method Details
#get_presence(user_id: 'me') ⇒ Object
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/legion/extensions/microsoft_teams/runners/presence.rb', line 24
def get_presence(user_id: 'me', **)
log.debug("Presence#get_presence user_id=#{user_id}")
conn = graph_connection(**)
response = conn.get("#{user_path(user_id)}/presence")
body = response.body || {}
{
availability: body['availability'],
activity: body['activity'],
fetched_at: Time.now.utc
}
rescue StandardError => e
handle_exception(e, level: :warn, operation: 'Presence#get_presence', user_id: user_id)
{ availability: 'Offline', activity: 'OffWork', error: e.message, fetched_at: Time.now.utc }
end
|