slack-ruby-client 0.13.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/FUNDING.yml +1 -0
- data/.github/workflows/integration_test.yml +26 -0
- data/.github/workflows/lint.yml +14 -0
- data/.github/workflows/pr_lint.yml +21 -0
- data/.github/workflows/test.yml +36 -0
- data/.gitignore +5 -3
- data/.rubocop.yml +34 -5
- data/.rubocop_todo.yml +180 -46
- data/.ruby-version +1 -0
- data/CHANGELOG.md +119 -2
- data/CONTRIBUTING.md +23 -11
- data/Dangerfile +2 -0
- data/Gemfile +22 -5
- data/Gemfile.danger +6 -0
- data/LICENSE.md +1 -1
- data/README.md +236 -101
- data/RELEASING.md +2 -2
- data/Rakefile +2 -1
- data/UPGRADING.md +100 -2
- data/bin/commands/admin_analytics.rb +16 -0
- data/bin/commands/admin_apps.rb +51 -0
- data/bin/commands/admin_apps_approved.rb +17 -0
- data/bin/commands/admin_apps_requests.rb +28 -0
- data/bin/commands/admin_apps_restricted.rb +17 -0
- data/bin/commands/admin_audit_anomaly_allow.rb +23 -0
- data/bin/commands/admin_auth_policy.rb +39 -0
- data/bin/commands/admin_barriers.rb +47 -0
- data/bin/commands/admin_conversations.rb +171 -0
- data/bin/commands/admin_conversations_ekm.rb +17 -0
- data/bin/commands/admin_conversations_restrictAccess.rb +37 -0
- data/bin/commands/admin_emoji.rb +54 -0
- data/bin/commands/admin_inviteRequests.rb +36 -0
- data/bin/commands/admin_inviteRequests_approved.rb +16 -0
- data/bin/commands/admin_inviteRequests_denied.rb +16 -0
- data/bin/commands/admin_teams.rb +27 -0
- data/bin/commands/admin_teams_admins.rb +16 -0
- data/bin/commands/admin_teams_owners.rb +16 -0
- data/bin/commands/admin_teams_settings.rb +64 -0
- data/bin/commands/admin_usergroups.rb +48 -0
- data/bin/commands/admin_users.rb +98 -0
- data/bin/commands/admin_users_session.rb +78 -0
- data/bin/commands/admin_users_unsupportedVersions.rb +15 -0
- data/bin/commands/api.rb +1 -1
- data/bin/commands/apps.rb +15 -0
- data/bin/commands/apps_connections.rb +13 -0
- data/bin/commands/apps_event_authorizations.rb +16 -0
- data/bin/commands/apps_manifest.rb +52 -0
- data/bin/commands/auth.rb +1 -0
- data/bin/commands/auth_teams.rb +16 -0
- data/bin/commands/bookmarks.rb +53 -0
- data/bin/commands/bots.rb +2 -0
- data/bin/commands/calls.rb +52 -0
- data/bin/commands/calls_participants.rb +25 -0
- data/bin/commands/chat.rb +61 -14
- data/bin/commands/chat_scheduledMessages.rb +19 -0
- data/bin/commands/conversations.rb +82 -10
- data/bin/commands/dialog.rb +1 -0
- data/bin/commands/dnd.rb +6 -3
- data/bin/commands/emoji.rb +1 -0
- data/bin/commands/files.rb +34 -18
- data/bin/commands/files_comments.rb +1 -21
- data/bin/commands/files_remote.rb +78 -0
- data/bin/commands/migration.rb +2 -0
- data/bin/commands/oauth.rb +2 -14
- data/bin/commands/oauth_v2.rb +29 -0
- data/bin/commands/openid_connect.rb +27 -0
- data/bin/commands/pins.rb +3 -6
- data/bin/commands/reactions.rb +3 -3
- data/bin/commands/reminders.rb +7 -0
- data/bin/commands/rtm.rb +1 -15
- data/bin/commands/search.rb +6 -1
- data/bin/commands/stars.rb +8 -6
- data/bin/commands/team.rb +6 -0
- data/bin/commands/team_billing.rb +13 -0
- data/bin/commands/team_preferences.rb +13 -0
- data/bin/commands/team_profile.rb +1 -0
- data/bin/commands/tooling_tokens.rb +14 -0
- data/bin/commands/usergroups.rb +7 -1
- data/bin/commands/usergroups_users.rb +3 -0
- data/bin/commands/users.rb +6 -4
- data/bin/commands/users_admin.rb +1 -0
- data/bin/commands/users_prefs.rb +1 -0
- data/bin/commands/users_profile.rb +6 -5
- data/bin/commands/views.rb +50 -0
- data/bin/commands/workflows.rb +38 -0
- data/bin/commands.rb +41 -8
- data/bin/slack +3 -4
- data/examples/hi_real_time_and_web/Gemfile +1 -0
- data/examples/hi_real_time_and_web/hi.rb +7 -3
- data/examples/hi_real_time_async_async/Gemfile +1 -0
- data/examples/hi_real_time_async_async/hi.rb +6 -2
- data/examples/hi_web/Gemfile +1 -0
- data/examples/hi_web/hi.rb +1 -0
- data/examples/new_ticket/Gemfile +1 -0
- data/examples/new_ticket/new_ticket.rb +1 -0
- data/lib/slack/config.rb +2 -2
- data/lib/slack/events/config.rb +32 -0
- data/lib/slack/events/request.rb +72 -0
- data/lib/slack/logger.rb +6 -5
- data/lib/slack/messages/formatting.rb +1 -0
- data/lib/slack/messages/message.rb +1 -4
- data/lib/slack/real_time/api/message.rb +6 -3
- data/lib/slack/real_time/api/message_id.rb +1 -0
- data/lib/slack/real_time/api/ping.rb +5 -2
- data/lib/slack/real_time/api/templates/event_handler.erb +5 -1
- data/lib/slack/real_time/api/typing.rb +5 -2
- data/lib/slack/real_time/client.rb +105 -54
- data/lib/slack/real_time/concurrency/async.rb +77 -6
- data/lib/slack/real_time/concurrency.rb +1 -2
- data/lib/slack/real_time/config.rb +9 -13
- data/lib/slack/real_time/models/base.rb +1 -4
- data/lib/slack/real_time/models/bot.rb +1 -0
- data/lib/slack/real_time/models/channel.rb +5 -0
- data/lib/slack/real_time/models/im.rb +1 -0
- data/lib/slack/real_time/models/{group.rb → mpim.rb} +2 -1
- data/lib/slack/real_time/models/team.rb +1 -0
- data/lib/slack/real_time/models/user.rb +1 -0
- data/lib/slack/real_time/models.rb +3 -1
- data/lib/slack/real_time/socket.rb +45 -17
- data/lib/slack/real_time/stores/base.rb +28 -14
- data/lib/slack/real_time/stores/starter.rb +325 -297
- data/lib/slack/real_time/stores/store.rb +271 -196
- data/lib/slack/real_time/stores.rb +2 -7
- data/lib/slack/version.rb +2 -1
- data/lib/slack/web/api/endpoints/admin_analytics.rb +28 -0
- data/lib/slack/web/api/endpoints/admin_apps.rb +78 -0
- data/lib/slack/web/api/endpoints/admin_apps_approved.rb +35 -0
- data/lib/slack/web/api/endpoints/admin_apps_requests.rb +51 -0
- data/lib/slack/web/api/endpoints/admin_apps_restricted.rb +35 -0
- data/lib/slack/web/api/endpoints/admin_audit_anomaly_allow.rb +34 -0
- data/lib/slack/web/api/endpoints/admin_auth_policy.rb +72 -0
- data/lib/slack/web/api/endpoints/admin_barriers.rb +82 -0
- data/lib/slack/web/api/endpoints/admin_conversations.rb +264 -0
- data/lib/slack/web/api/endpoints/admin_conversations_ekm.rb +35 -0
- data/lib/slack/web/api/endpoints/admin_conversations_restrictAccess.rb +61 -0
- data/lib/slack/web/api/endpoints/admin_emoji.rb +88 -0
- data/lib/slack/web/api/endpoints/admin_inviteRequests.rb +61 -0
- data/lib/slack/web/api/endpoints/admin_inviteRequests_approved.rb +33 -0
- data/lib/slack/web/api/endpoints/admin_inviteRequests_denied.rb +33 -0
- data/lib/slack/web/api/endpoints/admin_teams.rb +50 -0
- data/lib/slack/web/api/endpoints/admin_teams_admins.rb +34 -0
- data/lib/slack/web/api/endpoints/admin_teams_owners.rb +34 -0
- data/lib/slack/web/api/endpoints/admin_teams_settings.rb +99 -0
- data/lib/slack/web/api/endpoints/admin_usergroups.rb +77 -0
- data/lib/slack/web/api/endpoints/admin_users.rb +163 -0
- data/lib/slack/web/api/endpoints/admin_users_session.rb +122 -0
- data/lib/slack/web/api/endpoints/admin_users_unsupportedVersions.rb +25 -0
- data/lib/slack/web/api/endpoints/api.rb +2 -3
- data/lib/slack/web/api/endpoints/apps.rb +27 -0
- data/lib/slack/web/api/endpoints/apps_connections.rb +21 -0
- data/lib/slack/web/api/endpoints/apps_event_authorizations.rb +34 -0
- data/lib/slack/web/api/endpoints/apps_manifest.rb +77 -0
- data/lib/slack/web/api/endpoints/auth.rb +2 -1
- data/lib/slack/web/api/endpoints/auth_teams.rb +33 -0
- data/lib/slack/web/api/endpoints/bookmarks.rb +88 -0
- data/lib/slack/web/api/endpoints/bots.rb +4 -1
- data/lib/slack/web/api/endpoints/calls.rb +83 -0
- data/lib/slack/web/api/endpoints/calls_participants.rb +42 -0
- data/lib/slack/web/api/endpoints/chat.rb +168 -65
- data/lib/slack/web/api/endpoints/chat_scheduledMessages.rb +40 -0
- data/lib/slack/web/api/endpoints/conversations.rb +182 -67
- data/lib/slack/web/api/endpoints/dialog.rb +5 -4
- data/lib/slack/web/api/endpoints/dnd.rb +9 -4
- data/lib/slack/web/api/endpoints/emoji.rb +1 -0
- data/lib/slack/web/api/endpoints/files.rb +69 -37
- data/lib/slack/web/api/endpoints/files_comments.rb +4 -36
- data/lib/slack/web/api/endpoints/files_remote.rb +127 -0
- data/lib/slack/web/api/endpoints/migration.rb +6 -3
- data/lib/slack/web/api/endpoints/oauth.rb +7 -31
- data/lib/slack/web/api/endpoints/oauth_v2.rb +48 -0
- data/lib/slack/web/api/endpoints/openid_connect.rb +42 -0
- data/lib/slack/web/api/endpoints/pins.rb +11 -18
- data/lib/slack/web/api/endpoints/reactions.rb +22 -21
- data/lib/slack/web/api/endpoints/reminders.rb +23 -10
- data/lib/slack/web/api/endpoints/rtm.rb +3 -25
- data/lib/slack/web/api/endpoints/search.rb +31 -16
- data/lib/slack/web/api/endpoints/stars.rb +14 -11
- data/lib/slack/web/api/endpoints/team.rb +15 -4
- data/lib/slack/web/api/endpoints/team_billing.rb +21 -0
- data/lib/slack/web/api/endpoints/team_preferences.rb +21 -0
- data/lib/slack/web/api/endpoints/team_profile.rb +2 -1
- data/lib/slack/web/api/endpoints/tooling_tokens.rb +24 -0
- data/lib/slack/web/api/endpoints/usergroups.rb +31 -20
- data/lib/slack/web/api/endpoints/usergroups_users.rb +13 -8
- data/lib/slack/web/api/endpoints/users.rb +24 -23
- data/lib/slack/web/api/endpoints/users_admin.rb +3 -2
- data/lib/slack/web/api/endpoints/users_prefs.rb +1 -0
- data/lib/slack/web/api/endpoints/users_profile.rb +8 -7
- data/lib/slack/web/api/endpoints/views.rb +102 -0
- data/lib/slack/web/api/endpoints/workflows.rb +61 -0
- data/lib/slack/web/api/endpoints.rb +82 -18
- data/lib/slack/web/api/error.rb +1 -0
- data/lib/slack/web/api/errors/server_error.rb +37 -0
- data/lib/slack/web/api/errors/slack_error.rb +14 -1
- data/lib/slack/web/api/errors/too_many_requests_error.rb +2 -4
- data/lib/slack/web/api/errors.rb +1116 -0
- data/lib/slack/web/api/mixins/{channels.id.rb → conversations.id.rb} +5 -6
- data/lib/slack/web/api/mixins/ids.id.rb +3 -2
- data/lib/slack/web/api/mixins/users.id.rb +3 -4
- data/lib/slack/web/api/mixins/users.search.rb +3 -1
- data/lib/slack/web/api/mixins.rb +2 -2
- data/lib/slack/web/api/patches/chat.attachments-blocks.patch +69 -0
- data/lib/slack/web/api/patches/{dialog.1.open-json-support.patch → dialog.encoded-json.patch} +4 -4
- data/lib/slack/web/api/patches/views.view-json.patch +55 -0
- data/lib/slack/web/api/templates/command.erb +1 -0
- data/lib/slack/web/api/templates/commands.erb +1 -0
- data/lib/slack/web/api/templates/endpoints.erb +2 -2
- data/lib/slack/web/api/templates/errors.erb +20 -0
- data/lib/slack/web/api/templates/method.erb +6 -2
- data/lib/slack/web/api/templates/method_spec.erb +2 -1
- data/lib/slack/web/client.rb +2 -1
- data/lib/slack/web/config.rb +5 -2
- data/lib/slack/web/faraday/connection.rb +24 -20
- data/lib/slack/web/faraday/request.rb +5 -1
- data/lib/slack/web/faraday/response/raise_error.rb +14 -7
- data/lib/slack/web/faraday/response/wrap_error.rb +24 -0
- data/lib/slack/web/pagination/cursor.rb +7 -7
- data/lib/slack-ruby-client.rb +12 -5
- data/lib/slack.rb +1 -0
- data/lib/slack_ruby_client.rb +1 -0
- data/lib/tasks/git.rake +1 -0
- data/lib/tasks/real_time.rake +51 -21
- data/lib/tasks/update.rake +1 -0
- data/lib/tasks/web.rake +48 -12
- data/screenshots/create-app.png +0 -0
- data/slack-ruby-client.gemspec +7 -12
- data/spec/fixtures/slack/web/429_error.yml +50 -54
- data/spec/fixtures/slack/web/auth_test_error.yml +51 -18
- data/spec/fixtures/slack/web/auth_test_success.yml +50 -26
- data/spec/fixtures/slack/web/conversations_info.yml +167 -0
- data/spec/fixtures/slack/web/conversations_setTopic.yml +84 -0
- data/spec/fixtures/slack/web/conversations_setTopic_one_page.yml +172 -0
- data/spec/fixtures/slack/web/conversations_setTopic_paginated.yml +253 -0
- data/spec/fixtures/slack/web/paginated_users_list.yml +501 -69
- data/spec/fixtures/slack/web/rtm_connect.yml +347 -26
- data/spec/fixtures/slack/web/users_info.yml +153 -69
- data/spec/fixtures/slack/web/users_list.yml +102 -41
- data/spec/fixtures/slack/web/views_open_error.yml +83 -0
- data/spec/integration/integration_spec.rb +115 -47
- data/spec/slack/config_spec.rb +2 -0
- data/spec/slack/events/config_spec.rb +35 -0
- data/spec/slack/events/request_spec.rb +188 -0
- data/spec/slack/messages/formatting_spec.rb +35 -13
- data/spec/slack/real_time/api/message_spec.rb +7 -2
- data/spec/slack/real_time/api/ping_spec.rb +3 -1
- data/spec/slack/real_time/api/typing_spec.rb +6 -2
- data/spec/slack/real_time/client_spec.rb +300 -142
- data/spec/slack/real_time/concurrency/it_behaves_like_a_realtime_socket.rb +2 -0
- data/spec/slack/real_time/concurrency/with_concurrency_spec.rb +10 -0
- data/spec/slack/real_time/concurrency/without_concurrency_spec.rb +10 -0
- data/spec/slack/real_time/event_handlers/bot_spec.rb +20 -17
- data/spec/slack/real_time/event_handlers/event_handlers_spec.rb +3 -2
- data/spec/slack/real_time/event_handlers/im_spec.rb +31 -27
- data/spec/slack/real_time/event_handlers/{group_spec.rb → private_channel_spec.rb} +36 -27
- data/spec/slack/real_time/event_handlers/{channel_spec.rb → public_channel_spec.rb} +31 -24
- data/spec/slack/real_time/event_handlers/team_spec.rb +8 -7
- data/spec/slack/real_time/event_handlers/user_spec.rb +7 -5
- data/spec/slack/real_time/rtm_connect_spec.rb +2 -1
- data/spec/slack/real_time/stores/store_spec.rb +50 -0
- data/spec/slack/slack_spec.rb +41 -6
- data/spec/slack/version_spec.rb +2 -1
- data/spec/slack/web/api/endpoints/admin_analytics_spec.rb +13 -0
- data/spec/slack/web/api/endpoints/admin_apps_approved_spec.rb +8 -0
- data/spec/slack/web/api/endpoints/admin_apps_requests_spec.rb +13 -0
- data/spec/slack/web/api/endpoints/admin_apps_restricted_spec.rb +8 -0
- data/spec/slack/web/api/endpoints/admin_apps_spec.rb +18 -0
- data/spec/slack/web/api/endpoints/admin_audit_anomaly_allow_spec.rb +8 -0
- data/spec/slack/web/api/endpoints/admin_auth_policy_spec.rb +35 -0
- data/spec/slack/web/api/endpoints/admin_barriers_spec.rb +38 -0
- data/spec/slack/web/api/endpoints/admin_conversations_ekm_spec.rb +8 -0
- data/spec/slack/web/api/endpoints/admin_conversations_restrictAccess_spec.rb +32 -0
- data/spec/slack/web/api/endpoints/admin_conversations_spec.rb +98 -0
- data/spec/slack/web/api/endpoints/admin_emoji_spec.rb +37 -0
- data/spec/slack/web/api/endpoints/admin_inviteRequests_approved_spec.rb +8 -0
- data/spec/slack/web/api/endpoints/admin_inviteRequests_denied_spec.rb +8 -0
- data/spec/slack/web/api/endpoints/admin_inviteRequests_spec.rb +18 -0
- data/spec/slack/web/api/endpoints/admin_teams_admins_spec.rb +13 -0
- data/spec/slack/web/api/endpoints/admin_teams_owners_spec.rb +13 -0
- data/spec/slack/web/api/endpoints/admin_teams_settings_spec.rb +53 -0
- data/spec/slack/web/api/endpoints/admin_teams_spec.rb +16 -0
- data/spec/slack/web/api/endpoints/admin_usergroups_spec.rb +37 -0
- data/spec/slack/web/api/endpoints/admin_users_session_spec.rb +41 -0
- data/spec/slack/web/api/endpoints/admin_users_spec.rb +67 -0
- data/spec/slack/web/api/endpoints/admin_users_unsupportedVersions_spec.rb +8 -0
- data/spec/slack/web/api/endpoints/api_spec.rb +1 -0
- data/spec/slack/web/api/endpoints/apps_connections_spec.rb +8 -0
- data/spec/slack/web/api/endpoints/apps_event_authorizations_spec.rb +13 -0
- data/spec/slack/web/api/endpoints/apps_manifest_spec.rb +36 -0
- data/spec/slack/web/api/endpoints/apps_spec.rb +16 -0
- data/spec/slack/web/api/endpoints/{apps_permissions_resources_spec.rb → auth_teams_spec.rb} +2 -1
- data/spec/slack/web/api/endpoints/bookmarks_spec.rb +40 -0
- data/spec/slack/web/api/endpoints/bots_spec.rb +1 -0
- data/spec/slack/web/api/endpoints/calls_participants_spec.rb +24 -0
- data/spec/slack/web/api/endpoints/calls_spec.rb +31 -0
- data/spec/slack/web/api/endpoints/chat_scheduledMessages_spec.rb +8 -0
- data/spec/slack/web/api/endpoints/custom_specs/auth_spec.rb +9 -7
- data/spec/slack/web/api/endpoints/custom_specs/chat_spec.rb +144 -40
- data/spec/slack/web/api/endpoints/custom_specs/conversations_spec.rb +13 -0
- data/spec/slack/web/api/endpoints/custom_specs/dialog_spec.rb +18 -6
- data/spec/slack/web/api/endpoints/custom_specs/users_spec.rb +8 -3
- data/spec/slack/web/api/endpoints/custom_specs/views_spec.rb +112 -0
- data/spec/slack/web/api/endpoints/dnd_spec.rb +4 -3
- data/spec/slack/web/api/endpoints/emoji_spec.rb +1 -0
- data/spec/slack/web/api/endpoints/files_comments_spec.rb +3 -21
- data/spec/slack/web/api/endpoints/files_remote_spec.rb +24 -0
- data/spec/slack/web/api/endpoints/files_spec.rb +18 -4
- data/spec/slack/web/api/endpoints/migration_spec.rb +1 -0
- data/spec/slack/web/api/endpoints/oauth_spec.rb +1 -22
- data/spec/slack/web/api/endpoints/oauth_v2_spec.rb +16 -0
- data/spec/slack/web/api/endpoints/openid_connect_spec.rb +8 -0
- data/spec/slack/web/api/endpoints/pins_spec.rb +1 -0
- data/spec/slack/web/api/endpoints/reactions_spec.rb +8 -1
- data/spec/slack/web/api/endpoints/reminders_spec.rb +3 -2
- data/spec/slack/web/api/endpoints/rtm_spec.rb +1 -0
- data/spec/slack/web/api/endpoints/search_spec.rb +1 -0
- data/spec/slack/web/api/endpoints/stars_spec.rb +1 -0
- data/spec/slack/web/api/endpoints/{apps_permissions_scopes_spec.rb → team_billing_spec.rb} +2 -1
- data/spec/slack/web/api/endpoints/team_preferences_spec.rb +8 -0
- data/spec/slack/web/api/endpoints/team_profile_spec.rb +1 -0
- data/spec/slack/web/api/endpoints/team_spec.rb +1 -0
- data/spec/slack/web/api/endpoints/tooling_tokens_spec.rb +13 -0
- data/spec/slack/web/api/endpoints/usergroups_spec.rb +1 -0
- data/spec/slack/web/api/endpoints/usergroups_users_spec.rb +3 -2
- data/spec/slack/web/api/endpoints/users_admin_spec.rb +1 -0
- data/spec/slack/web/api/endpoints/users_prefs_spec.rb +1 -0
- data/spec/slack/web/api/endpoints/users_profile_spec.rb +1 -0
- data/spec/slack/web/api/endpoints/workflows_spec.rb +26 -0
- data/spec/slack/web/api/error_spec.rb +7 -7
- data/spec/slack/web/api/errors/slack_error_spec.rb +26 -7
- data/spec/slack/web/api/mixins/conversations_list_spec.rb +21 -0
- data/spec/slack/web/api/mixins/conversations_spec.rb +45 -0
- data/spec/slack/web/api/mixins/users_spec.rb +19 -8
- data/spec/slack/web/api/pagination/cursor_spec.rb +47 -15
- data/spec/slack/web/client_spec.rb +199 -22
- data/spec/slack/web/faraday/request_spec.rb +80 -0
- data/spec/slack/web/faraday/response/raise_error_spec.rb +48 -12
- data/spec/spec_helper.rb +9 -2
- data/spec/support/queue_with_timeout.rb +5 -4
- data/spec/support/real_time/concurrency/mock.rb +1 -0
- data/spec/support/real_time/connected_client.rb +6 -6
- data/spec/support/real_time/event.rb +1 -0
- data/spec/support/real_time/loaded_client.rb +120 -0
- data/spec/support/token.rb +1 -0
- data/spec/support/vcr.rb +37 -1
- metadata +174 -262
- data/.travis.yml +0 -32
- data/bin/commands/apps_permissions.rb +0 -22
- data/bin/commands/apps_permissions_resources.rb +0 -14
- data/bin/commands/apps_permissions_scopes.rb +0 -12
- data/bin/commands/apps_permissions_users.rb +0 -25
- data/bin/commands/channels.rb +0 -175
- data/bin/commands/groups.rb +0 -174
- data/bin/commands/im.rb +0 -67
- data/bin/commands/mpim.rb +0 -65
- data/examples/hi_real_time/Gemfile +0 -5
- data/examples/hi_real_time/hi.gif +0 -0
- data/examples/hi_real_time/hi.rb +0 -37
- data/examples/hi_real_time_async_celluloid/Gemfile +0 -6
- data/examples/hi_real_time_async_celluloid/Procfile +0 -2
- data/examples/hi_real_time_async_celluloid/hi.rb +0 -35
- data/examples/hi_real_time_async_eventmachine/Gemfile +0 -6
- data/examples/hi_real_time_async_eventmachine/Procfile +0 -2
- data/examples/hi_real_time_async_eventmachine/hi.rb +0 -35
- data/lib/slack/real_time/concurrency/celluloid.rb +0 -118
- data/lib/slack/real_time/concurrency/eventmachine.rb +0 -66
- data/lib/slack/web/api/endpoints/apps_permissions.rb +0 -35
- data/lib/slack/web/api/endpoints/apps_permissions_resources.rb +0 -30
- data/lib/slack/web/api/endpoints/apps_permissions_scopes.rb +0 -20
- data/lib/slack/web/api/endpoints/apps_permissions_users.rb +0 -49
- data/lib/slack/web/api/endpoints/channels.rb +0 -266
- data/lib/slack/web/api/endpoints/groups.rb +0 -265
- data/lib/slack/web/api/endpoints/im.rb +0 -113
- data/lib/slack/web/api/endpoints/mpim.rb +0 -108
- data/lib/slack/web/api/endpoints/presence.rb +0 -23
- data/lib/slack/web/api/mixins/channels.id.json +0 -20
- data/lib/slack/web/api/mixins/groups.id.json +0 -20
- data/lib/slack/web/api/mixins/groups.id.rb +0 -26
- data/lib/slack/web/api/patches/chat.1.text-attachments-required.patch +0 -13
- data/lib/slack/web/api/patches/chat.2.attachments-json.patch +0 -17
- data/lib/slack/web/api/patches/chat.3.update-attachments-support.patch +0 -21
- data/lib/slack/web/api/patches/chat.4.postEphemeral-attachments-support.patch +0 -17
- data/lib/slack/web/api/patches/chat.5.postEphemeral-text-or-attachments.patch +0 -13
- data/screenshots/register-bot.png +0 -0
- data/spec/fixtures/slack/web/503_error.yml +0 -14
- data/spec/fixtures/slack/web/channels_info.yml +0 -46
- data/spec/fixtures/slack/web/groups_info.yml +0 -43
- data/spec/fixtures/slack/web/rtm_start.yml +0 -104
- data/spec/slack/real_time/concurrency/celluloid_spec.rb +0 -106
- data/spec/slack/real_time/concurrency/eventmachine_spec.rb +0 -47
- data/spec/slack/real_time/rtm_start_spec.rb +0 -13
- data/spec/slack/real_time/store_spec.rb +0 -11
- data/spec/slack/web/api/endpoints/apps_permissions_spec.rb +0 -15
- data/spec/slack/web/api/endpoints/apps_permissions_users_spec.rb +0 -18
- data/spec/slack/web/api/endpoints/conversations_spec.rb +0 -100
- data/spec/slack/web/api/endpoints/custom_specs/channels_spec.rb +0 -11
- data/spec/slack/web/api/endpoints/custom_specs/groups_spec.rb +0 -11
- data/spec/slack/web/api/endpoints/im_spec.rb +0 -38
- data/spec/slack/web/api/endpoints/mpim_spec.rb +0 -38
- data/spec/slack/web/api/errors/service_unavailable_spec.rb +0 -14
- data/spec/slack/web/api/mixins/channels_spec.rb +0 -33
- data/spec/slack/web/api/mixins/groups_spec.rb +0 -33
@@ -1,180 +1,104 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Slack
|
2
4
|
module RealTime
|
3
5
|
module Stores
|
4
|
-
#
|
6
|
+
# Full store with initialization logic
|
5
7
|
class Store < Base
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
8
|
+
CONVERSATION_TYPES = {
|
9
|
+
public_channels: 'public_channel',
|
10
|
+
private_channels: 'private_channel',
|
11
|
+
ims: 'im',
|
12
|
+
mpims: 'mpim'
|
13
|
+
}.freeze
|
14
|
+
|
15
|
+
attr_reader :caches
|
16
|
+
|
17
|
+
def initialize(attrs, options = {})
|
18
|
+
@teams = {}
|
19
|
+
@users = {}
|
20
|
+
@bots = {}
|
21
|
+
@public_channels = {}
|
22
|
+
@private_channels = {}
|
23
|
+
@ims = {}
|
24
|
+
@mpims = {}
|
13
25
|
|
14
|
-
def initialize(attrs)
|
15
26
|
if attrs.team
|
16
27
|
@team_id = attrs.team.id
|
17
|
-
@teams
|
18
|
-
else
|
19
|
-
@teams = {}
|
28
|
+
@teams[@team_id] = Models::Team.new(attrs.team)
|
20
29
|
end
|
21
30
|
|
22
31
|
if attrs.self
|
23
32
|
@self_id = attrs.self.id
|
24
|
-
@users
|
25
|
-
else
|
26
|
-
@users = {}
|
33
|
+
@users[@self_id] = Models::User.new(attrs.self)
|
27
34
|
end
|
28
35
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
36
|
+
@caches =
|
37
|
+
if options[:caches].is_a?(Array) || options[:caches].nil?
|
38
|
+
caches = options[:caches].to_a.map(&:to_sym)
|
39
|
+
unknown_caches = caches - CACHES
|
40
|
+
raise ArgumentError, "Unknown caches: #{unknown_caches.join(', ')}" unless unknown_caches.empty?
|
41
|
+
|
42
|
+
Set.new(caches).freeze
|
43
|
+
elsif options[:caches] == :all
|
44
|
+
Set.new(CACHES).freeze
|
45
|
+
else
|
46
|
+
raise ArgumentError, 'Unexpected value for option `caches`. Expects :all or an array of caches'
|
33
47
|
end
|
34
|
-
|
35
|
-
|
36
|
-
@channels = {}
|
37
|
-
if attrs.channels
|
38
|
-
attrs.channels.each do |data|
|
39
|
-
@channels[data.id] = Models::Channel.new(data)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
@bots = {}
|
44
|
-
if attrs.bots
|
45
|
-
attrs.bots.each do |data|
|
46
|
-
@bots[data.id] = Models::Bot.new(data)
|
47
|
-
end
|
48
|
-
end
|
48
|
+
end
|
49
49
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
@groups[data.id] = Models::Group.new(data)
|
54
|
-
end
|
55
|
-
end
|
50
|
+
def self
|
51
|
+
users[@self_id]
|
52
|
+
end
|
56
53
|
|
57
|
-
|
58
|
-
|
59
|
-
attrs.ims.each do |data|
|
60
|
-
@ims[data.id] = Models::Im.new(data)
|
61
|
-
end
|
62
|
-
end
|
54
|
+
def team
|
55
|
+
teams[@team_id]
|
63
56
|
end
|
64
57
|
|
65
58
|
### RealTime Events
|
66
59
|
|
67
|
-
# A private channel was deleted.
|
68
|
-
# @see https://api.slack.com/events/group_deleted
|
69
|
-
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/group_deleted.json
|
70
|
-
# on :group_deleted do |data|
|
71
|
-
|
72
|
-
# Determine the current presence status for a list of users.
|
73
|
-
# @see https://api.slack.com/events/presence_query
|
74
|
-
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/presence_query.json
|
75
|
-
# on :presence_query do |data|
|
76
|
-
|
77
|
-
# The membership of an existing User Group has changed.
|
78
|
-
# @see https://api.slack.com/events/subteam_members_changed
|
79
|
-
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/subteam_members_changed.json
|
80
|
-
# on :subteam_members_changed do |data|
|
81
|
-
|
82
|
-
# Subscribe to presence events for the specified users.
|
83
|
-
# @see https://api.slack.com/events/presence_sub
|
84
|
-
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/presence_sub.json
|
85
|
-
# on :presence_sub do |data|
|
86
|
-
|
87
|
-
# A user left a public or private channel.
|
88
|
-
# @see https://api.slack.com/events/member_left_channel
|
89
|
-
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/member_left_channel.json
|
90
|
-
# on :member_left_channel do |data|
|
91
|
-
|
92
|
-
# A user joined a public or private channel.
|
93
|
-
# @see https://api.slack.com/events/member_joined_channel
|
94
|
-
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/member_joined_channel.json
|
95
|
-
# on :member_joined_channel do |data|
|
96
|
-
|
97
|
-
# The server intends to close the connection soon..
|
98
|
-
# @see https://api.slack.com/events/goodbye
|
99
|
-
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/goodbye.json
|
100
|
-
# on :goodbye do |data|
|
101
|
-
|
102
|
-
# Verifies ownership of an Events API Request URL.
|
103
|
-
# @see https://api.slack.com/events/url_verification
|
104
|
-
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/url_verification.json
|
105
|
-
# on :url_verification do |data|
|
106
|
-
|
107
|
-
# A message was posted in a multiparty direct message channel.
|
108
|
-
# @see https://api.slack.com/events/message.mpim
|
109
|
-
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/message.mpim.json
|
110
|
-
# on :message.mpim do |data|
|
111
|
-
|
112
|
-
# A message was posted in a direct message channel.
|
113
|
-
# @see https://api.slack.com/events/message.im
|
114
|
-
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/message.im.json
|
115
|
-
# on :message.im do |data|
|
116
|
-
|
117
|
-
# A message was posted to a private channel.
|
118
|
-
# @see https://api.slack.com/events/message.groups
|
119
|
-
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/message.groups.json
|
120
|
-
# on :message.groups do |data|
|
121
|
-
|
122
|
-
# A message was posted to a channel.
|
123
|
-
# @see https://api.slack.com/events/message.channels
|
124
|
-
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/message.channels.json
|
125
|
-
# on :message.channels do |data|
|
126
|
-
|
127
|
-
# A direct message read marker was updated.
|
128
|
-
# @see https://api.slack.com/events/im_marked
|
129
|
-
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/im_marked.json
|
130
|
-
# on :im_marked do |data|
|
131
|
-
|
132
|
-
# Bulk updates were made to a DM channel's history.
|
133
|
-
# @see https://api.slack.com/events/im_history_changed
|
134
|
-
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/im_history_changed.json
|
135
|
-
# on :im_history_changed do |data|
|
136
|
-
|
137
60
|
# The list of accounts a user is signed into has changed.
|
138
61
|
# @see https://api.slack.com/events/accounts_changed
|
139
62
|
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/accounts_changed.json
|
140
63
|
# on :accounts_changed do |data|
|
141
64
|
|
142
|
-
#
|
65
|
+
# A bot user was added.
|
143
66
|
# @see https://api.slack.com/events/bot_added
|
144
67
|
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/bot_added.json
|
145
68
|
on :bot_added do |data|
|
146
|
-
|
69
|
+
bot = Models::Bot.new(data.bot)
|
70
|
+
bots[bot.id] = bot
|
147
71
|
end
|
148
72
|
|
149
|
-
#
|
73
|
+
# A bot user was changed.
|
150
74
|
# @see https://api.slack.com/events/bot_changed
|
151
75
|
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/bot_changed.json
|
152
76
|
on :bot_changed do |data|
|
153
77
|
bot = bots[data.bot.id]
|
154
|
-
bot
|
78
|
+
bot&.merge!(data.bot)
|
155
79
|
end
|
156
80
|
|
157
|
-
# A
|
81
|
+
# A channel was archived.
|
158
82
|
# @see https://api.slack.com/events/channel_archive
|
159
83
|
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/channel_archive.json
|
160
84
|
on :channel_archive do |data|
|
161
|
-
channel =
|
85
|
+
channel = public_channels[data.channel]
|
162
86
|
channel.is_archived = true if channel
|
163
87
|
end
|
164
88
|
|
165
|
-
# A
|
89
|
+
# A channel was created.
|
166
90
|
# @see https://api.slack.com/events/channel_created
|
167
91
|
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/channel_created.json
|
168
92
|
on :channel_created do |data|
|
169
93
|
channel = Models::Channel.new(data.channel)
|
170
|
-
|
94
|
+
public_channels[channel.id] = channel
|
171
95
|
end
|
172
96
|
|
173
|
-
# A
|
97
|
+
# A channel was deleted.
|
174
98
|
# @see https://api.slack.com/events/channel_deleted
|
175
99
|
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/channel_deleted.json
|
176
100
|
on :channel_deleted do |data|
|
177
|
-
|
101
|
+
public_channels.delete(data.channel)
|
178
102
|
end
|
179
103
|
|
180
104
|
# Bulk updates were made to a channel's history.
|
@@ -187,11 +111,20 @@ module Slack
|
|
187
111
|
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/channel_joined.json
|
188
112
|
on :channel_joined do |data|
|
189
113
|
channel_id = data.channel.id
|
190
|
-
channel
|
191
|
-
|
192
|
-
channel
|
114
|
+
if data.channel.is_private?
|
115
|
+
channel = private_channels[channel_id]
|
116
|
+
if channel
|
117
|
+
channel.merge!(data.channel)
|
118
|
+
else
|
119
|
+
private_channels[channel_id] = Models::Channel.new(data.channel)
|
120
|
+
end
|
193
121
|
else
|
194
|
-
|
122
|
+
channel = public_channels[channel_id]
|
123
|
+
if channel
|
124
|
+
channel.merge!(data.channel)
|
125
|
+
else
|
126
|
+
public_channels[channel_id] = Models::Channel.new(data.channel)
|
127
|
+
end
|
195
128
|
end
|
196
129
|
end
|
197
130
|
|
@@ -199,8 +132,8 @@ module Slack
|
|
199
132
|
# @see https://api.slack.com/events/channel_left
|
200
133
|
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/channel_left.json
|
201
134
|
on :channel_left do |data|
|
202
|
-
channel =
|
203
|
-
channel
|
135
|
+
channel = public_channels[data.channel]
|
136
|
+
channel&.members&.delete(self.self.id)
|
204
137
|
end
|
205
138
|
|
206
139
|
# Your channel read marker was updated.
|
@@ -208,23 +141,23 @@ module Slack
|
|
208
141
|
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/channel_marked.json
|
209
142
|
# on :channel_marked do |data|
|
210
143
|
|
211
|
-
# A
|
144
|
+
# A channel was renamed.
|
212
145
|
# @see https://api.slack.com/events/channel_rename
|
213
146
|
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/channel_rename.json
|
214
147
|
on :channel_rename do |data|
|
215
|
-
channel =
|
216
|
-
channel
|
148
|
+
channel = public_channels[data.channel.id]
|
149
|
+
channel&.merge!(data.channel)
|
217
150
|
end
|
218
151
|
|
219
|
-
# A
|
152
|
+
# A channel was unarchived.
|
220
153
|
# @see https://api.slack.com/events/channel_unarchive
|
221
154
|
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/channel_unarchive.json
|
222
155
|
on :channel_unarchive do |data|
|
223
|
-
channel =
|
156
|
+
channel = public_channels[data.channel]
|
224
157
|
channel.is_archived = false if channel
|
225
158
|
end
|
226
159
|
|
227
|
-
# A
|
160
|
+
# A slash command has been added or changed.
|
228
161
|
# @see https://api.slack.com/events/commands_changed
|
229
162
|
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/commands_changed.json
|
230
163
|
# on :commands_changed do |data|
|
@@ -232,25 +165,40 @@ module Slack
|
|
232
165
|
# Do not Disturb settings changed for the current user.
|
233
166
|
# @see https://api.slack.com/events/dnd_updated
|
234
167
|
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/dnd_updated.json
|
235
|
-
|
168
|
+
on :dnd_updated do |data|
|
169
|
+
self.dnd_status = data.dnd_status
|
170
|
+
end
|
236
171
|
|
237
|
-
# Do not Disturb settings changed for a
|
172
|
+
# Do not Disturb settings changed for a member.
|
238
173
|
# @see https://api.slack.com/events/dnd_updated_user
|
239
174
|
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/dnd_updated_user.json
|
240
|
-
|
175
|
+
on :dnd_updated_user do |data|
|
176
|
+
user = users[data.user]
|
177
|
+
user.dnd_status = data.dnd_status if user
|
178
|
+
end
|
241
179
|
|
242
|
-
# The
|
180
|
+
# The workspace email domain has changed.
|
243
181
|
# @see https://api.slack.com/events/email_domain_changed
|
244
182
|
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/email_domain_changed.json
|
245
183
|
on :email_domain_changed do |data|
|
246
184
|
team.email_domain = data.email_domain
|
247
185
|
end
|
248
186
|
|
249
|
-
# A
|
187
|
+
# A custom emoji has been added or changed.
|
250
188
|
# @see https://api.slack.com/events/emoji_changed
|
251
189
|
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/emoji_changed.json
|
252
190
|
# on :emoji_changed do |data|
|
253
191
|
|
192
|
+
# An enterprise grid migration has finished on an external workspace..
|
193
|
+
# @see https://api.slack.com/events/external_org_migration_finished
|
194
|
+
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/external_org_migration_finished.json
|
195
|
+
# on :external_org_migration_finished do |data|
|
196
|
+
|
197
|
+
# An enterprise grid migration has started on an external workspace..
|
198
|
+
# @see https://api.slack.com/events/external_org_migration_started
|
199
|
+
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/external_org_migration_started.json
|
200
|
+
# on :external_org_migration_started do |data|
|
201
|
+
|
254
202
|
# A file was changed.
|
255
203
|
# @see https://api.slack.com/events/file_change
|
256
204
|
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/file_change.json
|
@@ -259,7 +207,7 @@ module Slack
|
|
259
207
|
# A file comment was added.
|
260
208
|
# @see https://api.slack.com/events/file_comment_added
|
261
209
|
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/file_comment_added.json
|
262
|
-
# on :file_comment_added do |data|
|
210
|
+
# on :file_comment_added do |data|
|
263
211
|
|
264
212
|
# A file comment was deleted.
|
265
213
|
# @see https://api.slack.com/events/file_comment_deleted
|
@@ -281,11 +229,6 @@ module Slack
|
|
281
229
|
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/file_deleted.json
|
282
230
|
# on :file_deleted do |data|
|
283
231
|
|
284
|
-
# A file was made private.
|
285
|
-
# @see https://api.slack.com/events/file_private
|
286
|
-
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/file_private.json
|
287
|
-
# on :file_private do |data|
|
288
|
-
|
289
232
|
# A file was made public.
|
290
233
|
# @see https://api.slack.com/events/file_public
|
291
234
|
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/file_public.json
|
@@ -301,85 +244,157 @@ module Slack
|
|
301
244
|
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/file_unshared.json
|
302
245
|
# on :file_unshared do |data|
|
303
246
|
|
304
|
-
#
|
247
|
+
# The server intends to close the connection soon..
|
248
|
+
# @see https://api.slack.com/events/goodbye
|
249
|
+
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/goodbye.json
|
250
|
+
# on :goodbye do |data|
|
251
|
+
|
252
|
+
# A private channel was archived.
|
305
253
|
# @see https://api.slack.com/events/group_archive
|
306
254
|
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/group_archive.json
|
307
255
|
on :group_archive do |data|
|
308
|
-
channel =
|
256
|
+
channel = private_channels[data.channel]
|
309
257
|
channel.is_archived = true if channel
|
310
258
|
end
|
311
259
|
|
312
|
-
# You closed a
|
260
|
+
# You closed a private channel.
|
313
261
|
# @see https://api.slack.com/events/group_close
|
314
262
|
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/group_close.json
|
315
263
|
on :group_close do |data|
|
316
|
-
|
264
|
+
channel = private_channels[data.channel]
|
265
|
+
channel.is_open = false if channel
|
266
|
+
end
|
267
|
+
|
268
|
+
# A private channel was deleted.
|
269
|
+
# @see https://api.slack.com/events/group_deleted
|
270
|
+
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/group_deleted.json
|
271
|
+
on :group_deleted do |data|
|
272
|
+
private_channels.delete(data.channel)
|
317
273
|
end
|
318
274
|
|
319
|
-
# Bulk updates were made to a
|
275
|
+
# Bulk updates were made to a private channel's history.
|
320
276
|
# @see https://api.slack.com/events/group_history_changed
|
321
277
|
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/group_history_changed.json
|
322
278
|
# on :group_history_changed do |data|
|
323
279
|
|
324
|
-
# You joined a private
|
280
|
+
# You joined a private channel.
|
325
281
|
# @see https://api.slack.com/events/group_joined
|
326
282
|
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/group_joined.json
|
327
283
|
on :group_joined do |data|
|
328
|
-
|
284
|
+
channel = Models::Channel.new(data.channel)
|
285
|
+
private_channels[channel.id] = channel
|
329
286
|
end
|
330
287
|
|
331
|
-
# You left a private
|
288
|
+
# You left a private channel.
|
332
289
|
# @see https://api.slack.com/events/group_left
|
333
290
|
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/group_left.json
|
334
291
|
on :group_left do |data|
|
335
|
-
channel
|
336
|
-
|
292
|
+
# Deleting because we can't access a private channel when we're not a member
|
293
|
+
private_channels.delete(data.channel)
|
337
294
|
end
|
338
295
|
|
339
|
-
# A private
|
296
|
+
# A private channel read marker was updated.
|
340
297
|
# @see https://api.slack.com/events/group_marked
|
341
298
|
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/group_marked.json
|
342
299
|
# on :group_marked do |data|
|
343
300
|
|
344
|
-
# You
|
301
|
+
# You created a group DM.
|
345
302
|
# @see https://api.slack.com/events/group_open
|
346
303
|
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/group_open.json
|
347
304
|
on :group_open do |data|
|
348
|
-
|
305
|
+
channel = private_channels[data.channel]
|
306
|
+
channel.is_open = true if channel
|
349
307
|
end
|
350
308
|
|
351
|
-
# A private
|
309
|
+
# A private channel was renamed.
|
352
310
|
# @see https://api.slack.com/events/group_rename
|
353
311
|
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/group_rename.json
|
354
312
|
on :group_rename do |data|
|
355
|
-
channel =
|
356
|
-
channel
|
313
|
+
channel = private_channels[data.channel.id]
|
314
|
+
channel&.merge!(data.channel)
|
357
315
|
end
|
358
316
|
|
359
|
-
# A private
|
317
|
+
# A private channel was unarchived.
|
360
318
|
# @see https://api.slack.com/events/group_unarchive
|
361
319
|
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/group_unarchive.json
|
362
320
|
on :group_unarchive do |data|
|
363
|
-
channel =
|
321
|
+
channel = private_channels[data.channel]
|
364
322
|
channel.is_archived = false if channel
|
365
323
|
end
|
366
324
|
|
367
|
-
#
|
325
|
+
# The client has successfully connected to the server.
|
326
|
+
# @see https://api.slack.com/events/hello
|
327
|
+
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/hello.json
|
328
|
+
on :hello do |_data, client|
|
329
|
+
# rubocop:disable Metrics/BlockNesting
|
330
|
+
if caches.include?(:teams)
|
331
|
+
team_info = client.web_client.team_info
|
332
|
+
team = Models::Team.new(team_info.team)
|
333
|
+
teams[team.id] = teams.key?(team.id) ? teams[team.id].merge(team) : team
|
334
|
+
end
|
335
|
+
|
336
|
+
if caches.include?(:users) || caches.include?(:bots)
|
337
|
+
client.web_client.users_list do |users_list|
|
338
|
+
users_list.members.each do |user_data|
|
339
|
+
if caches.include?(:users)
|
340
|
+
user = Models::User.new(user_data)
|
341
|
+
users[user.id] = users.key?(user.id) ? users[user.id].merge(user) : user
|
342
|
+
end
|
343
|
+
|
344
|
+
next unless user_data.is_bot? && caches.include?(:bots)
|
345
|
+
|
346
|
+
bot_info = client.web_client.bots_info(bot: user_data.profile.bot_id)
|
347
|
+
bot = Models::Bot.new(bot_info.bot)
|
348
|
+
bots[bot.id] = bots.key?(bot.id) ? bots[bot.id].merge(bot) : bot
|
349
|
+
end
|
350
|
+
end
|
351
|
+
end
|
352
|
+
|
353
|
+
if caches.include?(:public_channels) || caches.include?(:private_channels) ||
|
354
|
+
caches.include?(:ims) || caches.include?(:mpims)
|
355
|
+
types = CONVERSATION_TYPES.slice(*caches).values.join(',')
|
356
|
+
client.web_client.conversations_list(types: types) do |conversations|
|
357
|
+
conversations.channels.each do |channel_data|
|
358
|
+
if channel_data.is_mpim?
|
359
|
+
mpim = Models::Mpim.new(channel_data)
|
360
|
+
mpims[mpim.id] = mpims.key?(mpim.id) ? mpims[mpim.id].merge(mpim) : mpim
|
361
|
+
elsif channel_data.is_im?
|
362
|
+
im = Models::Im.new(channel_data)
|
363
|
+
ims[im.id] = ims.key?(im.id) ? ims[im.id].merge(im) : im
|
364
|
+
elsif channel_data.is_channel? || channel_data.is_group?
|
365
|
+
channel = Models::Channel.new(channel_data)
|
366
|
+
if channel.is_private?
|
367
|
+
private_channels[channel.id] =
|
368
|
+
private_channels.key?(channel.id) ? private_channels[channel.id].merge(channel) : channel
|
369
|
+
else
|
370
|
+
public_channels[channel.id] =
|
371
|
+
public_channels.key?(channel.id) ? public_channels[channel.id].merge(channel) : channel
|
372
|
+
end
|
373
|
+
end
|
374
|
+
end
|
375
|
+
end
|
376
|
+
end
|
377
|
+
# rubocop:enable Metrics/BlockNesting
|
378
|
+
end
|
379
|
+
|
380
|
+
# You closed a DM.
|
368
381
|
# @see https://api.slack.com/events/im_close
|
369
382
|
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/im_close.json
|
370
383
|
on :im_close do |data|
|
371
|
-
return unless ims
|
384
|
+
return unless ims&.key?(data.channel)
|
385
|
+
|
372
386
|
ims[data.channel].is_open = false
|
373
387
|
end
|
374
388
|
|
375
|
-
# A
|
389
|
+
# A DM was created.
|
376
390
|
# @see https://api.slack.com/events/im_created
|
377
391
|
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/im_created.json
|
378
392
|
on :im_created do |data|
|
379
|
-
|
393
|
+
im = Models::Im.new(data.channel)
|
394
|
+
ims[im.id] = im
|
380
395
|
end
|
381
396
|
|
382
|
-
# Bulk updates were made to a DM
|
397
|
+
# Bulk updates were made to a DM's history.
|
383
398
|
# @see https://api.slack.com/events/im_history_changed
|
384
399
|
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/im_history_changed.json
|
385
400
|
# on :im_history_changed do |data|
|
@@ -389,11 +404,12 @@ module Slack
|
|
389
404
|
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/im_marked.json
|
390
405
|
# on :im_marked do |data|
|
391
406
|
|
392
|
-
# You opened a
|
407
|
+
# You opened a DM.
|
393
408
|
# @see https://api.slack.com/events/im_open
|
394
409
|
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/im_open.json
|
395
410
|
on :im_open do |data|
|
396
|
-
return unless ims
|
411
|
+
return unless ims&.key?(data.channel)
|
412
|
+
|
397
413
|
ims[data.channel].is_open = true
|
398
414
|
end
|
399
415
|
|
@@ -404,6 +420,25 @@ module Slack
|
|
404
420
|
self.self.presence = data.presence
|
405
421
|
end
|
406
422
|
|
423
|
+
# A user joined a public channel, private channel or MPDM..
|
424
|
+
# @see https://api.slack.com/events/member_joined_channel
|
425
|
+
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/member_joined_channel.json
|
426
|
+
on :member_joined_channel do |data|
|
427
|
+
channel = public_channels[data.channel] || private_channels[data.channel]
|
428
|
+
if channel
|
429
|
+
channel.members ||= Set.new
|
430
|
+
channel.members << data.user
|
431
|
+
end
|
432
|
+
end
|
433
|
+
|
434
|
+
# A user left a public or private channel.
|
435
|
+
# @see https://api.slack.com/events/member_left_channel
|
436
|
+
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/member_left_channel.json
|
437
|
+
on :member_left_channel do |data|
|
438
|
+
channel = public_channels[data.channel] || private_channels[data.channel]
|
439
|
+
channel&.members&.delete(data.user)
|
440
|
+
end
|
441
|
+
|
407
442
|
# A pin was added to a channel.
|
408
443
|
# @see https://api.slack.com/events/pin_added
|
409
444
|
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/pin_added.json
|
@@ -422,7 +457,7 @@ module Slack
|
|
422
457
|
self.self.prefs[data.name] = data.value
|
423
458
|
end
|
424
459
|
|
425
|
-
# A
|
460
|
+
# A member's presence changed.
|
426
461
|
# @see https://api.slack.com/events/presence_change
|
427
462
|
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/presence_change.json
|
428
463
|
on :presence_change do |data|
|
@@ -430,12 +465,22 @@ module Slack
|
|
430
465
|
user.presence = data.presence if user
|
431
466
|
end
|
432
467
|
|
433
|
-
#
|
468
|
+
# Determine the current presence status for a list of users.
|
469
|
+
# @see https://api.slack.com/events/presence_query
|
470
|
+
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/presence_query.json
|
471
|
+
# on :presence_query do |data|
|
472
|
+
|
473
|
+
# Subscribe to presence events for the specified users.
|
474
|
+
# @see https://api.slack.com/events/presence_sub
|
475
|
+
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/presence_sub.json
|
476
|
+
# on :presence_sub do |data|
|
477
|
+
|
478
|
+
# A member has added an emoji reaction to an item.
|
434
479
|
# @see https://api.slack.com/events/reaction_added
|
435
480
|
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/reaction_added.json
|
436
481
|
# on :reaction_added do |data|
|
437
482
|
|
438
|
-
# A
|
483
|
+
# A member removed an emoji reaction.
|
439
484
|
# @see https://api.slack.com/events/reaction_removed
|
440
485
|
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/reaction_removed.json
|
441
486
|
# on :reaction_removed do |data|
|
@@ -445,37 +490,47 @@ module Slack
|
|
445
490
|
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/reconnect_url.json
|
446
491
|
# on :reconnect_url do |data|
|
447
492
|
|
448
|
-
# A
|
493
|
+
# A shared channel invite was sent to a Slack user.
|
494
|
+
# @see https://api.slack.com/events/shared_channel_invite_received
|
495
|
+
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/shared_channel_invite_received.json
|
496
|
+
# on :shared_channel_invite_received do |data|
|
497
|
+
|
498
|
+
# A member has starred an item.
|
449
499
|
# @see https://api.slack.com/events/star_added
|
450
500
|
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/star_added.json
|
451
501
|
# on :star_added do |data|
|
452
502
|
|
453
|
-
# A
|
503
|
+
# A member removed a star.
|
454
504
|
# @see https://api.slack.com/events/star_removed
|
455
505
|
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/star_removed.json
|
456
506
|
# on :star_removed do |data|
|
457
507
|
|
458
|
-
# A
|
508
|
+
# A User Group has been added to the workspace.
|
459
509
|
# @see https://api.slack.com/events/subteam_created
|
460
510
|
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/subteam_created.json
|
461
511
|
# on :subteam_created do |data|
|
462
512
|
|
463
|
-
#
|
513
|
+
# The membership of an existing User Group has changed.
|
514
|
+
# @see https://api.slack.com/events/subteam_members_changed
|
515
|
+
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/subteam_members_changed.json
|
516
|
+
# on :subteam_members_changed do |data|
|
517
|
+
|
518
|
+
# You have been added to a User Group.
|
464
519
|
# @see https://api.slack.com/events/subteam_self_added
|
465
520
|
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/subteam_self_added.json
|
466
521
|
# on :subteam_self_added do |data|
|
467
522
|
|
468
|
-
# You have been removed from a
|
523
|
+
# You have been removed from a User Group.
|
469
524
|
# @see https://api.slack.com/events/subteam_self_removed
|
470
525
|
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/subteam_self_removed.json
|
471
526
|
# on :subteam_self_removed do |data|
|
472
527
|
|
473
|
-
# An existing
|
528
|
+
# An existing User Group has been updated or its members changed.
|
474
529
|
# @see https://api.slack.com/events/subteam_updated
|
475
530
|
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/subteam_updated.json
|
476
531
|
# on :subteam_updated do |data|
|
477
532
|
|
478
|
-
# The
|
533
|
+
# The workspace domain has changed.
|
479
534
|
# @see https://api.slack.com/events/team_domain_change
|
480
535
|
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/team_domain_change.json
|
481
536
|
on :team_domain_change do |data|
|
@@ -483,26 +538,27 @@ module Slack
|
|
483
538
|
team.domain = data.domain
|
484
539
|
end
|
485
540
|
|
486
|
-
# A new
|
541
|
+
# A new member has joined.
|
487
542
|
# @see https://api.slack.com/events/team_join
|
488
543
|
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/team_join.json
|
489
544
|
on :team_join do |data|
|
490
|
-
|
545
|
+
user = Models::User.new(data.user)
|
546
|
+
users[user.id] = user
|
491
547
|
end
|
492
548
|
|
493
|
-
# The
|
549
|
+
# The workspace is being migrated between servers.
|
494
550
|
# @see https://api.slack.com/events/team_migration_started
|
495
551
|
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/team_migration_started.json
|
496
552
|
# on :team_migration_started do |data|
|
497
553
|
|
498
|
-
# The
|
554
|
+
# The account billing plan has changed.
|
499
555
|
# @see https://api.slack.com/events/team_plan_change
|
500
556
|
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/team_plan_change.json
|
501
557
|
on :team_plan_change do |data|
|
502
558
|
team.plan = data.plan
|
503
559
|
end
|
504
560
|
|
505
|
-
# A
|
561
|
+
# A preference has been updated.
|
506
562
|
# @see https://api.slack.com/events/team_pref_change
|
507
563
|
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/team_pref_change.json
|
508
564
|
on :team_pref_change do |data|
|
@@ -510,34 +566,53 @@ module Slack
|
|
510
566
|
team.prefs[data.name] = data.value
|
511
567
|
end
|
512
568
|
|
513
|
-
#
|
569
|
+
# The workspace profile fields have been updated.
|
514
570
|
# @see https://api.slack.com/events/team_profile_change
|
515
571
|
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/team_profile_change.json
|
516
572
|
# on :team_profile_change do |data|
|
517
573
|
|
518
|
-
#
|
574
|
+
# The workspace profile fields have been deleted.
|
519
575
|
# @see https://api.slack.com/events/team_profile_delete
|
520
576
|
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/team_profile_delete.json
|
521
577
|
# on :team_profile_delete do |data|
|
522
578
|
|
523
|
-
#
|
579
|
+
# The workspace profile fields have been reordered.
|
524
580
|
# @see https://api.slack.com/events/team_profile_reorder
|
525
581
|
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/team_profile_reorder.json
|
526
582
|
# on :team_profile_reorder do |data|
|
527
583
|
|
528
|
-
# The
|
584
|
+
# The workspace name has changed.
|
529
585
|
# @see https://api.slack.com/events/team_rename
|
530
586
|
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/team_rename.json
|
531
587
|
on :team_rename do |data|
|
532
588
|
team.name = data.name
|
533
589
|
end
|
534
590
|
|
535
|
-
# A
|
591
|
+
# A member's data has changed.
|
536
592
|
# @see https://api.slack.com/events/user_change
|
537
593
|
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/user_change.json
|
538
594
|
on :user_change do |data|
|
539
|
-
|
540
|
-
|
595
|
+
user = Models::User.new(data.user)
|
596
|
+
users[user.id] = user
|
597
|
+
end
|
598
|
+
|
599
|
+
# A user's huddle status has changed.
|
600
|
+
# @see https://api.slack.com/events/user_huddle_changed
|
601
|
+
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/user_huddle_changed.json
|
602
|
+
# on :user_huddle_changed do |data|
|
603
|
+
# (handled by :user_change)
|
604
|
+
|
605
|
+
# A user's profile data has changed.
|
606
|
+
# @see https://api.slack.com/events/user_profile_changed
|
607
|
+
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/user_profile_changed.json
|
608
|
+
# on :user_profile_changed do |data|
|
609
|
+
# (handled by :user_change)
|
610
|
+
|
611
|
+
# A user's status has changed.
|
612
|
+
# @see https://api.slack.com/events/user_status_changed
|
613
|
+
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/user_status_changed.json
|
614
|
+
# on :user_status_changed do |data|
|
615
|
+
# (handled by :user_change)
|
541
616
|
|
542
617
|
# A channel member is typing a message.
|
543
618
|
# @see https://api.slack.com/events/user_typing
|