mirror of
https://github.com/System-End/hackatime.git
synced 2026-04-19 16:38:23 +00:00
12 lines
447 B
Ruby
12 lines
447 B
Ruby
class SlackChannel
|
|
def self.find_by_id(id, force_refresh: false)
|
|
cached_name = Rails.cache.fetch("slack_channel_#{id}", expires_in: 1.week, force: force_refresh) do
|
|
response = HTTP.headers(Authorization: "Bearer #{ENV.fetch("SAILORS_LOG_SLACK_BOT_OAUTH_TOKEN")}").get("https://slack.com/api/conversations.info?channel=#{id}")
|
|
data = JSON.parse(response.body)
|
|
|
|
data.dig("channel", "name")
|
|
end
|
|
|
|
cached_name
|
|
end
|
|
end
|