| 1 | package slack |
| 2 | |
| 3 | import ( |
| 4 | "bytes" |
| 5 | "context" |
| 6 | "fmt" |
| 7 | "net/url" |
| 8 | "strconv" |
| 9 | "strings" |
| 10 | "time" |
| 11 | ) |
| 12 | |
| 13 | type UserPrefsCarrier struct { |
| 14 | SlackResponse |
| 15 | UserPrefs *UserPrefs `json:"prefs"` |
| 16 | } |
| 17 | |
| 18 | // UserPrefs carries a bunch of user settings including some unknown types |
| 19 | type UserPrefs struct { |
| 20 | UserColors string `json:"user_colors,omitempty"` |
| 21 | ColorNamesInList bool `json:"color_names_in_list,omitempty"` |
| 22 | // Keyboard UnknownType `json:"keyboard"` |
| 23 | EmailAlerts string `json:"email_alerts,omitempty"` |
| 24 | EmailAlertsSleepUntil int `json:"email_alerts_sleep_until,omitempty"` |
| 25 | EmailTips bool `json:"email_tips,omitempty"` |
| 26 | EmailWeekly bool `json:"email_weekly,omitempty"` |
| 27 | EmailOffers bool `json:"email_offers,omitempty"` |
| 28 | EmailResearch bool `json:"email_research,omitempty"` |
| 29 | EmailDeveloper bool `json:"email_developer,omitempty"` |
| 30 | WelcomeMessageHidden bool `json:"welcome_message_hidden,omitempty"` |
| 31 | SearchSort string `json:"search_sort,omitempty"` |
| 32 | SearchFileSort string `json:"search_file_sort,omitempty"` |
| 33 | SearchChannelSort string `json:"search_channel_sort,omitempty"` |
| 34 | SearchPeopleSort string `json:"search_people_sort,omitempty"` |
| 35 | ExpandInlineImages bool `json:"expand_inline_images,omitempty"` |
| 36 | ExpandInternalInlineImages bool `json:"expand_internal_inline_images,omitempty"` |
| 37 | ExpandSnippets bool `json:"expand_snippets,omitempty"` |
| 38 | PostsFormattingGuide bool `json:"posts_formatting_guide,omitempty"` |
| 39 | SeenWelcome2 bool `json:"seen_welcome_2,omitempty"` |
| 40 | SeenSSBPrompt bool `json:"seen_ssb_prompt,omitempty"` |
| 41 | SpacesNewXpBannerDismissed bool `json:"spaces_new_xp_banner_dismissed,omitempty"` |
| 42 | SearchOnlyMyChannels bool `json:"search_only_my_channels,omitempty"` |
| 43 | SearchOnlyCurrentTeam bool `json:"search_only_current_team,omitempty"` |
| 44 | SearchHideMyChannels bool `json:"search_hide_my_channels,omitempty"` |
| 45 | SearchOnlyShowOnline bool `json:"search_only_show_online,omitempty"` |
| 46 | SearchHideDeactivatedUsers bool `json:"search_hide_deactivated_users,omitempty"` |
| 47 | EmojiMode string `json:"emoji_mode,omitempty"` |
| 48 | EmojiUse string `json:"emoji_use,omitempty"` |
| 49 | HasInvited bool `json:"has_invited,omitempty"` |
| 50 | HasUploaded bool `json:"has_uploaded,omitempty"` |
| 51 | HasCreatedChannel bool `json:"has_created_channel,omitempty"` |
| 52 | HasSearched bool `json:"has_searched,omitempty"` |
| 53 | SearchExcludeChannels string `json:"search_exclude_channels,omitempty"` |
| 54 | MessagesTheme string `json:"messages_theme,omitempty"` |
| 55 | WebappSpellcheck bool `json:"webapp_spellcheck,omitempty"` |
| 56 | NoJoinedOverlays bool `json:"no_joined_overlays,omitempty"` |
| 57 | NoCreatedOverlays bool `json:"no_created_overlays,omitempty"` |
| 58 | DropboxEnabled bool `json:"dropbox_enabled,omitempty"` |
| 59 | SeenDomainInviteReminder bool `json:"seen_domain_invite_reminder,omitempty"` |
| 60 | SeenMemberInviteReminder bool `json:"seen_member_invite_reminder,omitempty"` |
| 61 | MuteSounds bool `json:"mute_sounds,omitempty"` |
| 62 | ArrowHistory bool `json:"arrow_history,omitempty"` |
| 63 | TabUIReturnSelects bool `json:"tab_ui_return_selects,omitempty"` |
| 64 | ObeyInlineImgLimit bool `json:"obey_inline_img_limit,omitempty"` |
| 65 | RequireAt bool `json:"require_at,omitempty"` |
| 66 | SsbSpaceWindow string `json:"ssb_space_window,omitempty"` |
| 67 | MacSsbBounce string `json:"mac_ssb_bounce,omitempty"` |
| 68 | MacSsbBullet bool `json:"mac_ssb_bullet,omitempty"` |
| 69 | ExpandNonMediaAttachments bool `json:"expand_non_media_attachments,omitempty"` |
| 70 | ShowTyping bool `json:"show_typing,omitempty"` |
| 71 | PagekeysHandled bool `json:"pagekeys_handled,omitempty"` |
| 72 | LastSnippetType string `json:"last_snippet_type,omitempty"` |
| 73 | DisplayRealNamesOverride int `json:"display_real_names_override,omitempty"` |
| 74 | DisplayDisplayNames bool `json:"display_display_names,omitempty"` |
| 75 | Time24 bool `json:"time24,omitempty"` |
| 76 | EnterIsSpecialInTbt bool `json:"enter_is_special_in_tbt,omitempty"` |
| 77 | MsgInputSendBtn bool `json:"msg_input_send_btn,omitempty"` |
| 78 | MsgInputSendBtnAutoSet bool `json:"msg_input_send_btn_auto_set,omitempty"` |
| 79 | MsgInputStickyComposer bool `json:"msg_input_sticky_composer,omitempty"` |
| 80 | GraphicEmoticons bool `json:"graphic_emoticons,omitempty"` |
| 81 | ConvertEmoticons bool `json:"convert_emoticons,omitempty"` |
| 82 | SsEmojis bool `json:"ss_emojis,omitempty"` |
| 83 | SeenOnboardingStart bool `json:"seen_onboarding_start,omitempty"` |
| 84 | OnboardingCancelled bool `json:"onboarding_cancelled,omitempty"` |
| 85 | SeenOnboardingSlackbotConversation bool `json:"seen_onboarding_slackbot_conversation,omitempty"` |
| 86 | SeenOnboardingChannels bool `json:"seen_onboarding_channels,omitempty"` |
| 87 | SeenOnboardingDirectMessages bool `json:"seen_onboarding_direct_messages,omitempty"` |
| 88 | SeenOnboardingInvites bool `json:"seen_onboarding_invites,omitempty"` |
| 89 | SeenOnboardingSearch bool `json:"seen_onboarding_search,omitempty"` |
| 90 | SeenOnboardingRecentMentions bool `json:"seen_onboarding_recent_mentions,omitempty"` |
| 91 | SeenOnboardingStarredItems bool `json:"seen_onboarding_starred_items,omitempty"` |
| 92 | SeenOnboardingPrivateGroups bool `json:"seen_onboarding_private_groups,omitempty"` |
| 93 | SeenOnboardingBanner bool `json:"seen_onboarding_banner,omitempty"` |
| 94 | OnboardingSlackbotConversationStep int `json:"onboarding_slackbot_conversation_step,omitempty"` |
| 95 | SetTzAutomatically bool `json:"set_tz_automatically,omitempty"` |
| 96 | SuppressLinkWarning bool `json:"suppress_link_warning,omitempty"` |
| 97 | DndEnabled bool `json:"dnd_enabled,omitempty"` |
| 98 | DndStartHour string `json:"dnd_start_hour,omitempty"` |
| 99 | DndEndHour string `json:"dnd_end_hour,omitempty"` |
| 100 | DndBeforeMonday string `json:"dnd_before_monday,omitempty"` |
| 101 | DndAfterMonday string `json:"dnd_after_monday,omitempty"` |
| 102 | DndEnabledMonday string `json:"dnd_enabled_monday,omitempty"` |
| 103 | DndBeforeTuesday string `json:"dnd_before_tuesday,omitempty"` |
| 104 | DndAfterTuesday string `json:"dnd_after_tuesday,omitempty"` |
| 105 | DndEnabledTuesday string `json:"dnd_enabled_tuesday,omitempty"` |
| 106 | DndBeforeWednesday string `json:"dnd_before_wednesday,omitempty"` |
| 107 | DndAfterWednesday string `json:"dnd_after_wednesday,omitempty"` |
| 108 | DndEnabledWednesday string `json:"dnd_enabled_wednesday,omitempty"` |
| 109 | DndBeforeThursday string `json:"dnd_before_thursday,omitempty"` |
| 110 | DndAfterThursday string `json:"dnd_after_thursday,omitempty"` |
| 111 | DndEnabledThursday string `json:"dnd_enabled_thursday,omitempty"` |
| 112 | DndBeforeFriday string `json:"dnd_before_friday,omitempty"` |
| 113 | DndAfterFriday string `json:"dnd_after_friday,omitempty"` |
| 114 | DndEnabledFriday string `json:"dnd_enabled_friday,omitempty"` |
| 115 | DndBeforeSaturday string `json:"dnd_before_saturday,omitempty"` |
| 116 | DndAfterSaturday string `json:"dnd_after_saturday,omitempty"` |
| 117 | DndEnabledSaturday string `json:"dnd_enabled_saturday,omitempty"` |
| 118 | DndBeforeSunday string `json:"dnd_before_sunday,omitempty"` |
| 119 | DndAfterSunday string `json:"dnd_after_sunday,omitempty"` |
| 120 | DndEnabledSunday string `json:"dnd_enabled_sunday,omitempty"` |
| 121 | DndDays string `json:"dnd_days,omitempty"` |
| 122 | DndCustomNewBadgeSeen bool `json:"dnd_custom_new_badge_seen,omitempty"` |
| 123 | DndNotificationScheduleNewBadgeSeen bool `json:"dnd_notification_schedule_new_badge_seen,omitempty"` |
| 124 | // UnreadCollapsedChannels unknownType `json:"unread_collapsed_channels,omitempty"` |
| 125 | SidebarBehavior string `json:"sidebar_behavior,omitempty"` |
| 126 | ChannelSort string `json:"channel_sort,omitempty"` |
| 127 | SeparatePrivateChannels bool `json:"separate_private_channels,omitempty"` |
| 128 | SeparateSharedChannels bool `json:"separate_shared_channels,omitempty"` |
| 129 | SidebarTheme string `json:"sidebar_theme,omitempty"` |
| 130 | SidebarThemeCustomValues string `json:"sidebar_theme_custom_values,omitempty"` |
| 131 | NoInvitesWidgetInSidebar bool `json:"no_invites_widget_in_sidebar,omitempty"` |
| 132 | NoOmniboxInChannels bool `json:"no_omnibox_in_channels,omitempty"` |
| 133 | |
| 134 | KKeyOmniboxAutoHideCount int `json:"k_key_omnibox_auto_hide_count,omitempty"` |
| 135 | ShowSidebarQuickswitcherButton bool `json:"show_sidebar_quickswitcher_button,omitempty"` |
| 136 | EntOrgWideChannelsSidebar bool `json:"ent_org_wide_channels_sidebar,omitempty"` |
| 137 | MarkMsgsReadImmediately bool `json:"mark_msgs_read_immediately,omitempty"` |
| 138 | StartScrollAtOldest bool `json:"start_scroll_at_oldest,omitempty"` |
| 139 | SnippetEditorWrapLongLines bool `json:"snippet_editor_wrap_long_lines,omitempty"` |
| 140 | LsDisabled bool `json:"ls_disabled,omitempty"` |
| 141 | FKeySearch bool `json:"f_key_search,omitempty"` |
| 142 | KKeyOmnibox bool `json:"k_key_omnibox,omitempty"` |
| 143 | PromptedForEmailDisabling bool `json:"prompted_for_email_disabling,omitempty"` |
| 144 | NoMacelectronBanner bool `json:"no_macelectron_banner,omitempty"` |
| 145 | NoMacssb1Banner bool `json:"no_macssb1_banner,omitempty"` |
| 146 | NoMacssb2Banner bool `json:"no_macssb2_banner,omitempty"` |
| 147 | NoWinssb1Banner bool `json:"no_winssb1_banner,omitempty"` |
| 148 | HideUserGroupInfoPane bool `json:"hide_user_group_info_pane,omitempty"` |
| 149 | MentionsExcludeAtUserGroups bool `json:"mentions_exclude_at_user_groups,omitempty"` |
| 150 | MentionsExcludeReactions bool `json:"mentions_exclude_reactions,omitempty"` |
| 151 | PrivacyPolicySeen bool `json:"privacy_policy_seen,omitempty"` |
| 152 | EnterpriseMigrationSeen bool `json:"enterprise_migration_seen,omitempty"` |
| 153 | LastTosAcknowledged string `json:"last_tos_acknowledged,omitempty"` |
| 154 | SearchExcludeBots bool `json:"search_exclude_bots,omitempty"` |
| 155 | LoadLato2 bool `json:"load_lato_2,omitempty"` |
| 156 | FullerTimestamps bool `json:"fuller_timestamps,omitempty"` |
| 157 | LastSeenAtChannelWarning int `json:"last_seen_at_channel_warning,omitempty"` |
| 158 | EmojiAutocompleteBig bool `json:"emoji_autocomplete_big,omitempty"` |
| 159 | TwoFactorAuthEnabled bool `json:"two_factor_auth_enabled,omitempty"` |
| 160 | // TwoFactorType unknownType `json:"two_factor_type,omitempty"` |
| 161 | // TwoFactorBackupType unknownType `json:"two_factor_backup_type,omitempty"` |
| 162 | HideHexSwatch bool `json:"hide_hex_swatch,omitempty"` |
| 163 | ShowJumperScores bool `json:"show_jumper_scores,omitempty"` |
| 164 | EnterpriseMdmCustomMsg string `json:"enterprise_mdm_custom_msg,omitempty"` |
| 165 | // EnterpriseExcludedAppTeams unknownType `json:"enterprise_excluded_app_teams,omitempty"` |
| 166 | ClientLogsPri string `json:"client_logs_pri,omitempty"` |
| 167 | FlannelServerPool string `json:"flannel_server_pool,omitempty"` |
| 168 | MentionsExcludeAtChannels bool `json:"mentions_exclude_at_channels,omitempty"` |
| 169 | ConfirmClearAllUnreads bool `json:"confirm_clear_all_unreads,omitempty"` |
| 170 | ConfirmUserMarkedAway bool `json:"confirm_user_marked_away,omitempty"` |
| 171 | BoxEnabled bool `json:"box_enabled,omitempty"` |
| 172 | SeenSingleEmojiMsg bool `json:"seen_single_emoji_msg,omitempty"` |
| 173 | ConfirmShCallStart bool `json:"confirm_sh_call_start,omitempty"` |
| 174 | PreferredSkinTone string `json:"preferred_skin_tone,omitempty"` |
| 175 | ShowAllSkinTones bool `json:"show_all_skin_tones,omitempty"` |
| 176 | WhatsNewRead int `json:"whats_new_read,omitempty"` |
| 177 | // FrecencyJumper unknownType `json:"frecency_jumper,omitempty"` |
| 178 | FrecencyEntJumper string `json:"frecency_ent_jumper,omitempty"` |
| 179 | FrecencyEntJumperBackup string `json:"frecency_ent_jumper_backup,omitempty"` |
| 180 | Jumbomoji bool `json:"jumbomoji,omitempty"` |
| 181 | NewxpSeenLastMessage int `json:"newxp_seen_last_message,omitempty"` |
| 182 | ShowMemoryInstrument bool `json:"show_memory_instrument,omitempty"` |
| 183 | EnableUnreadView bool `json:"enable_unread_view,omitempty"` |
| 184 | SeenUnreadViewCoachmark bool `json:"seen_unread_view_coachmark,omitempty"` |
| 185 | EnableReactEmojiPicker bool `json:"enable_react_emoji_picker,omitempty"` |
| 186 | SeenCustomStatusBadge bool `json:"seen_custom_status_badge,omitempty"` |
| 187 | SeenCustomStatusCallout bool `json:"seen_custom_status_callout,omitempty"` |
| 188 | SeenCustomStatusExpirationBadge bool `json:"seen_custom_status_expiration_badge,omitempty"` |
| 189 | UsedCustomStatusKbShortcut bool `json:"used_custom_status_kb_shortcut,omitempty"` |
| 190 | SeenGuestAdminSlackbotAnnouncement bool `json:"seen_guest_admin_slackbot_announcement,omitempty"` |
| 191 | SeenThreadsNotificationBanner bool `json:"seen_threads_notification_banner,omitempty"` |
| 192 | SeenNameTaggingCoachmark bool `json:"seen_name_tagging_coachmark,omitempty"` |
| 193 | AllUnreadsSortOrder string `json:"all_unreads_sort_order,omitempty"` |
| 194 | Locale string `json:"locale,omitempty"` |
| 195 | SeenIntlChannelNamesCoachmark bool `json:"seen_intl_channel_names_coachmark,omitempty"` |
| 196 | SeenP2LocaleChangeMessage int `json:"seen_p2_locale_change_message,omitempty"` |
| 197 | SeenLocaleChangeMessage int `json:"seen_locale_change_message,omitempty"` |
| 198 | SeenJapaneseLocaleChangeMessage bool `json:"seen_japanese_locale_change_message,omitempty"` |
| 199 | SeenSharedChannelsCoachmark bool `json:"seen_shared_channels_coachmark,omitempty"` |
| 200 | SeenSharedChannelsOptInChangeMessage bool `json:"seen_shared_channels_opt_in_change_message,omitempty"` |
| 201 | HasRecentlySharedaChannel bool `json:"has_recently_shared_a_channel,omitempty"` |
| 202 | SeenChannelBrowserAdminCoachmark bool `json:"seen_channel_browser_admin_coachmark,omitempty"` |
| 203 | SeenAdministrationMenu bool `json:"seen_administration_menu,omitempty"` |
| 204 | SeenDraftsSectionCoachmark bool `json:"seen_drafts_section_coachmark,omitempty"` |
| 205 | SeenEmojiUpdateOverlayCoachmark bool `json:"seen_emoji_update_overlay_coachmark,omitempty"` |
| 206 | SeenSonicDeluxeToast int `json:"seen_sonic_deluxe_toast,omitempty"` |
| 207 | SeenWysiwygDeluxeToast bool `json:"seen_wysiwyg_deluxe_toast,omitempty"` |
| 208 | SeenMarkdownPasteToast int `json:"seen_markdown_paste_toast,omitempty"` |
| 209 | SeenMarkdownPasteShortcut int `json:"seen_markdown_paste_shortcut,omitempty"` |
| 210 | SeenIaEducation bool `json:"seen_ia_education,omitempty"` |
| 211 | PlainTextMode bool `json:"plain_text_mode,omitempty"` |
| 212 | ShowSharedChannelsEducationBanner bool `json:"show_shared_channels_education_banner,omitempty"` |
| 213 | AllowCallsToSetCurrentStatus bool `json:"allow_calls_to_set_current_status,omitempty"` |
| 214 | InInteractiveMasMigrationFlow bool `json:"in_interactive_mas_migration_flow,omitempty"` |
| 215 | SunsetInteractiveMessageViews int `json:"sunset_interactive_message_views,omitempty"` |
| 216 | ShdepPromoCodeSubmitted bool `json:"shdep_promo_code_submitted,omitempty"` |
| 217 | SeenShdepSlackbotMessage bool `json:"seen_shdep_slackbot_message,omitempty"` |
| 218 | SeenCallsInteractiveCoachmark bool `json:"seen_calls_interactive_coachmark,omitempty"` |
| 219 | AllowCmdTabIss bool `json:"allow_cmd_tab_iss,omitempty"` |
| 220 | SeenWorkflowBuilderDeluxeToast bool `json:"seen_workflow_builder_deluxe_toast,omitempty"` |
| 221 | WorkflowBuilderIntroModalClickedThrough bool `json:"workflow_builder_intro_modal_clicked_through,omitempty"` |
| 222 | // WorkflowBuilderCoachmarks unknownType `json:"workflow_builder_coachmarks,omitempty"` |
| 223 | SeenGdriveCoachmark bool `json:"seen_gdrive_coachmark,omitempty"` |
| 224 | OverloadedMessageEnabled bool `json:"overloaded_message_enabled,omitempty"` |
| 225 | SeenHighlightsCoachmark bool `json:"seen_highlights_coachmark,omitempty"` |
| 226 | SeenHighlightsArrowsCoachmark bool `json:"seen_highlights_arrows_coachmark,omitempty"` |
| 227 | SeenHighlightsWarmWelcome bool `json:"seen_highlights_warm_welcome,omitempty"` |
| 228 | SeenNewSearchUi bool `json:"seen_new_search_ui,omitempty"` |
| 229 | SeenChannelSearch bool `json:"seen_channel_search,omitempty"` |
| 230 | SeenPeopleSearch bool `json:"seen_people_search,omitempty"` |
| 231 | SeenPeopleSearchCount int `json:"seen_people_search_count,omitempty"` |
| 232 | DismissedScrollSearchTooltipCount int `json:"dismissed_scroll_search_tooltip_count,omitempty"` |
| 233 | LastDismissedScrollSearchTooltipTimestamp int `json:"last_dismissed_scroll_search_tooltip_timestamp,omitempty"` |
| 234 | HasUsedQuickswitcherShortcut bool `json:"has_used_quickswitcher_shortcut,omitempty"` |
| 235 | SeenQuickswitcherShortcutTipCount int `json:"seen_quickswitcher_shortcut_tip_count,omitempty"` |
| 236 | BrowsersDismissedChannelsLowResultsEducation bool `json:"browsers_dismissed_channels_low_results_education,omitempty"` |
| 237 | BrowsersSeenInitialChannelsEducation bool `json:"browsers_seen_initial_channels_education,omitempty"` |
| 238 | BrowsersDismissedPeopleLowResultsEducation bool `json:"browsers_dismissed_people_low_results_education,omitempty"` |
| 239 | BrowsersSeenInitialPeopleEducation bool `json:"browsers_seen_initial_people_education,omitempty"` |
| 240 | BrowsersDismissedUserGroupsLowResultsEducation bool `json:"browsers_dismissed_user_groups_low_results_education,omitempty"` |
| 241 | BrowsersSeenInitialUserGroupsEducation bool `json:"browsers_seen_initial_user_groups_education,omitempty"` |
| 242 | BrowsersDismissedFilesLowResultsEducation bool `json:"browsers_dismissed_files_low_results_education,omitempty"` |
| 243 | BrowsersSeenInitialFilesEducation bool `json:"browsers_seen_initial_files_education,omitempty"` |
| 244 | A11yAnimations bool `json:"a11y_animations,omitempty"` |
| 245 | SeenKeyboardShortcutsCoachmark bool `json:"seen_keyboard_shortcuts_coachmark,omitempty"` |
| 246 | NeedsInitialPasswordSet bool `json:"needs_initial_password_set,omitempty"` |
| 247 | LessonsEnabled bool `json:"lessons_enabled,omitempty"` |
| 248 | TractorEnabled bool `json:"tractor_enabled,omitempty"` |
| 249 | TractorExperimentGroup string `json:"tractor_experiment_group,omitempty"` |
| 250 | OpenedSlackbotDm bool `json:"opened_slackbot_dm,omitempty"` |
| 251 | NewxpSuggestedChannels string `json:"newxp_suggested_channels,omitempty"` |
| 252 | OnboardingComplete bool `json:"onboarding_complete,omitempty"` |
| 253 | WelcomePlaceState string `json:"welcome_place_state,omitempty"` |
| 254 | // OnboardingRoleApps unknownType `json:"onboarding_role_apps,omitempty"` |
| 255 | HasReceivedThreadedMessage bool `json:"has_received_threaded_message,omitempty"` |
| 256 | SendYourFirstMessageBannerEnabled bool `json:"send_your_first_message_banner_enabled,omitempty"` |
| 257 | WhocanseethisDmMpdmBadge bool `json:"whocanseethis_dm_mpdm_badge,omitempty"` |
| 258 | HighlightWords string `json:"highlight_words,omitempty"` |
| 259 | ThreadsEverything bool `json:"threads_everything,omitempty"` |
| 260 | NoTextInNotifications bool `json:"no_text_in_notifications,omitempty"` |
| 261 | PushShowPreview bool `json:"push_show_preview,omitempty"` |
| 262 | GrowlsEnabled bool `json:"growls_enabled,omitempty"` |
| 263 | AllChannelsLoud bool `json:"all_channels_loud,omitempty"` |
| 264 | PushDmAlert bool `json:"push_dm_alert,omitempty"` |
| 265 | PushMentionAlert bool `json:"push_mention_alert,omitempty"` |
| 266 | PushEverything bool `json:"push_everything,omitempty"` |
| 267 | PushIdleWait int `json:"push_idle_wait,omitempty"` |
| 268 | PushSound string `json:"push_sound,omitempty"` |
| 269 | NewMsgSnd string `json:"new_msg_snd,omitempty"` |
| 270 | PushLoudChannels string `json:"push_loud_channels,omitempty"` |
| 271 | PushMentionChannels string `json:"push_mention_channels,omitempty"` |
| 272 | PushLoudChannelsSet string `json:"push_loud_channels_set,omitempty"` |
| 273 | LoudChannels string `json:"loud_channels,omitempty"` |
| 274 | NeverChannels string `json:"never_channels,omitempty"` |
| 275 | LoudChannelsSet string `json:"loud_channels_set,omitempty"` |
| 276 | AtChannelSuppressedChannels string `json:"at_channel_suppressed_channels,omitempty"` |
| 277 | PushAtChannelSuppressedChannels string `json:"push_at_channel_suppressed_channels,omitempty"` |
| 278 | MutedChannels string `json:"muted_channels,omitempty"` |
| 279 | // AllNotificationsPrefs unknownType `json:"all_notifications_prefs,omitempty"` |
| 280 | GrowthMsgLimitApproachingCtaCount int `json:"growth_msg_limit_approaching_cta_count,omitempty"` |
| 281 | GrowthMsgLimitApproachingCtaTs int `json:"growth_msg_limit_approaching_cta_ts,omitempty"` |
| 282 | GrowthMsgLimitReachedCtaCount int `json:"growth_msg_limit_reached_cta_count,omitempty"` |
| 283 | GrowthMsgLimitReachedCtaLastTs int `json:"growth_msg_limit_reached_cta_last_ts,omitempty"` |
| 284 | GrowthMsgLimitLongReachedCtaCount int `json:"growth_msg_limit_long_reached_cta_count,omitempty"` |
| 285 | GrowthMsgLimitLongReachedCtaLastTs int `json:"growth_msg_limit_long_reached_cta_last_ts,omitempty"` |
| 286 | GrowthMsgLimitSixtyDayBannerCtaCount int `json:"growth_msg_limit_sixty_day_banner_cta_count,omitempty"` |
| 287 | GrowthMsgLimitSixtyDayBannerCtaLastTs int `json:"growth_msg_limit_sixty_day_banner_cta_last_ts,omitempty"` |
| 288 | // GrowthAllBannersPrefs unknownType `json:"growth_all_banners_prefs,omitempty"` |
| 289 | AnalyticsUpsellCoachmarkSeen bool `json:"analytics_upsell_coachmark_seen,omitempty"` |
| 290 | SeenAppSpaceCoachmark bool `json:"seen_app_space_coachmark,omitempty"` |
| 291 | SeenAppSpaceTutorial bool `json:"seen_app_space_tutorial,omitempty"` |
| 292 | DismissedAppLauncherWelcome bool `json:"dismissed_app_launcher_welcome,omitempty"` |
| 293 | DismissedAppLauncherLimit bool `json:"dismissed_app_launcher_limit,omitempty"` |
| 294 | Purchaser bool `json:"purchaser,omitempty"` |
| 295 | ShowEntOnboarding bool `json:"show_ent_onboarding,omitempty"` |
| 296 | FoldersEnabled bool `json:"folders_enabled,omitempty"` |
| 297 | // FolderData unknownType `json:"folder_data,omitempty"` |
| 298 | SeenCorporateExportAlert bool `json:"seen_corporate_export_alert,omitempty"` |
| 299 | ShowAutocompleteHelp int `json:"show_autocomplete_help,omitempty"` |
| 300 | DeprecationToastLastSeen int `json:"deprecation_toast_last_seen,omitempty"` |
| 301 | DeprecationModalLastSeen int `json:"deprecation_modal_last_seen,omitempty"` |
| 302 | Iap1Lab int `json:"iap1_lab,omitempty"` |
| 303 | IaTopNavTheme string `json:"ia_top_nav_theme,omitempty"` |
| 304 | IaPlatformActionsLab int `json:"ia_platform_actions_lab,omitempty"` |
| 305 | ActivityView string `json:"activity_view,omitempty"` |
| 306 | FailoverProxyCheckCompleted int `json:"failover_proxy_check_completed,omitempty"` |
| 307 | EdgeUploadProxyCheckCompleted int `json:"edge_upload_proxy_check_completed,omitempty"` |
| 308 | AppSubdomainCheckCompleted int `json:"app_subdomain_check_completed,omitempty"` |
| 309 | AddAppsPromptDismissed bool `json:"add_apps_prompt_dismissed,omitempty"` |
| 310 | AddChannelPromptDismissed bool `json:"add_channel_prompt_dismissed,omitempty"` |
| 311 | ChannelSidebarHideInvite bool `json:"channel_sidebar_hide_invite,omitempty"` |
| 312 | InProdSurveysEnabled bool `json:"in_prod_surveys_enabled,omitempty"` |
| 313 | DismissedInstalledAppDmSuggestions string `json:"dismissed_installed_app_dm_suggestions,omitempty"` |
| 314 | SeenContextualMessageShortcutsModal bool `json:"seen_contextual_message_shortcuts_modal,omitempty"` |
| 315 | SeenMessageNavigationEducationalToast bool `json:"seen_message_navigation_educational_toast,omitempty"` |
| 316 | ContextualMessageShortcutsModalWasSeen bool `json:"contextual_message_shortcuts_modal_was_seen,omitempty"` |
| 317 | MessageNavigationToastWasSeen bool `json:"message_navigation_toast_was_seen,omitempty"` |
| 318 | UpToBrowseKbShortcut bool `json:"up_to_browse_kb_shortcut,omitempty"` |
| 319 | ChannelSections string `json:"channel_sections,omitempty"` |
| 320 | TZ string `json:"tz,omitempty"` |
| 321 | } |
| 322 | |
| 323 | func (api *Client) GetUserPrefs() (*UserPrefsCarrier, error) { |
| 324 | return api.GetUserPrefsContext(context.Background()) |
| 325 | } |
| 326 | |
| 327 | func (api *Client) GetUserPrefsContext(ctx context.Context) (*UserPrefsCarrier, error) { |
| 328 | response := UserPrefsCarrier{} |
| 329 | |
| 330 | err := api.getMethod(ctx, "users.prefs.get", api.token, url.Values{}, &response) |
| 331 | if err != nil { |
| 332 | return nil, err |
| 333 | } |
| 334 | |
| 335 | return &response, response.Err() |
| 336 | } |
| 337 | |
| 338 | func (api *Client) MuteChat(channelID string) (*UserPrefsCarrier, error) { |
| 339 | prefs, err := api.GetUserPrefs() |
| 340 | if err != nil { |
| 341 | return nil, err |
| 342 | } |
| 343 | chnls := strings.Split(prefs.UserPrefs.MutedChannels, ",") |
| 344 | for _, chn := range chnls { |
| 345 | if chn == channelID { |
| 346 | return nil, nil // noop |
| 347 | } |
| 348 | } |
| 349 | newChnls := prefs.UserPrefs.MutedChannels + "," + channelID |
| 350 | values := url.Values{"token": {api.token}, "muted_channels": {newChnls}, "reason": {"update-muted-channels"}} |
| 351 | response := UserPrefsCarrier{} |
| 352 | |
| 353 | err = api.postMethod(context.Background(), "users.prefs.set", values, &response) |
| 354 | if err != nil { |
| 355 | return nil, err |
| 356 | } |
| 357 | |
| 358 | return &response, response.Err() |
| 359 | } |
| 360 | |
| 361 | func (api *Client) UnMuteChat(channelID string) (*UserPrefsCarrier, error) { |
| 362 | prefs, err := api.GetUserPrefs() |
| 363 | if err != nil { |
| 364 | return nil, err |
| 365 | } |
| 366 | chnls := strings.Split(prefs.UserPrefs.MutedChannels, ",") |
| 367 | newChnls := make([]string, len(chnls)-1) |
| 368 | for i, chn := range chnls { |
| 369 | if chn == channelID { |
| 370 | return nil, nil // noop |
| 371 | } |
| 372 | newChnls[i] = chn |
| 373 | } |
| 374 | values := url.Values{"token": {api.token}, "muted_channels": {strings.Join(newChnls, ",")}, "reason": {"update-muted-channels"}} |
| 375 | response := UserPrefsCarrier{} |
| 376 | |
| 377 | err = api.postMethod(context.Background(), "users.prefs.set", values, &response) |
| 378 | if err != nil { |
| 379 | return nil, err |
| 380 | } |
| 381 | |
| 382 | return &response, response.Err() |
| 383 | } |
| 384 | |
| 385 | // UserDetails contains user details coming in the initial response from StartRTM |
| 386 | type UserDetails struct { |
| 387 | ID string `json:"id"` |
| 388 | Name string `json:"name"` |
| 389 | Created JSONTime `json:"created"` |
| 390 | ManualPresence string `json:"manual_presence"` |
| 391 | Prefs UserPrefs `json:"prefs"` |
| 392 | } |
| 393 | |
| 394 | // JSONTime exists so that we can have a String method converting the date |
| 395 | type JSONTime int64 |
| 396 | |
| 397 | // String converts the unix timestamp into a string |
| 398 | func (t JSONTime) String() string { |
| 399 | tm := t.Time() |
| 400 | return fmt.Sprintf("\"%s\"", tm.Format("Mon Jan _2")) |
| 401 | } |
| 402 | |
| 403 | // Time returns a `time.Time` representation of this value. |
| 404 | func (t JSONTime) Time() time.Time { |
| 405 | return time.Unix(int64(t), 0) |
| 406 | } |
| 407 | |
| 408 | // UnmarshalJSON will unmarshal both string and int JSON values |
| 409 | func (t *JSONTime) UnmarshalJSON(buf []byte) error { |
| 410 | s := bytes.Trim(buf, `"`) |
| 411 | |
| 412 | if bytes.EqualFold(s, []byte("null")) { |
| 413 | *t = JSONTime(0) |
| 414 | return nil |
| 415 | } |
| 416 | |
| 417 | v, err := strconv.Atoi(string(s)) |
| 418 | if err != nil { |
| 419 | return err |
| 420 | } |
| 421 | |
| 422 | *t = JSONTime(int64(v)) |
| 423 | return nil |
| 424 | } |
| 425 | |
| 426 | // Team contains details about a team |
| 427 | type Team struct { |
| 428 | ID string `json:"id"` |
| 429 | Name string `json:"name"` |
| 430 | Domain string `json:"domain"` |
| 431 | } |
| 432 | |
| 433 | // Icons XXX: needs further investigation |
| 434 | type Icons struct { |
| 435 | Image36 string `json:"image_36,omitempty"` |
| 436 | Image48 string `json:"image_48,omitempty"` |
| 437 | Image72 string `json:"image_72,omitempty"` |
| 438 | } |
| 439 | |
| 440 | // Info contains various details about the authenticated user and team. |
| 441 | // It is returned by StartRTM or included in the "ConnectedEvent" RTM event. |
| 442 | type Info struct { |
| 443 | URL string `json:"url,omitempty"` |
| 444 | User *UserDetails `json:"self,omitempty"` |
| 445 | Team *Team `json:"team,omitempty"` |
| 446 | } |
| 447 | |
| 448 | type infoResponseFull struct { |
| 449 | Info |
| 450 | SlackResponse |
| 451 | } |
| 452 | |
| 453 | // GetBotByID is deprecated and returns nil |
| 454 | func (info Info) GetBotByID(botID string) *Bot { |
| 455 | return nil |
| 456 | } |
| 457 | |
| 458 | // GetUserByID is deprecated and returns nil |
| 459 | func (info Info) GetUserByID(userID string) *User { |
| 460 | return nil |
| 461 | } |
| 462 | |
| 463 | // GetChannelByID is deprecated and returns nil |
| 464 | func (info Info) GetChannelByID(channelID string) *Channel { |
| 465 | return nil |
| 466 | } |
| 467 | |
| 468 | // GetGroupByID is deprecated and returns nil |
| 469 | func (info Info) GetGroupByID(groupID string) *Group { |
| 470 | return nil |
| 471 | } |
| 472 | |
| 473 | // GetIMByID is deprecated and returns nil |
| 474 | func (info Info) GetIMByID(imID string) *IM { |
| 475 | return nil |
| 476 | } |