@mtkruto/node 0.67.1 → 0.68.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/0_errors.js +2 -6
- package/esm/3_errors.js +2 -12
- package/esm/3_transport.d.ts +3 -3
- package/esm/3_transport.js +3 -3
- package/esm/3_types.d.ts +8 -7
- package/esm/3_types.d.ts.map +1 -1
- package/esm/3_types.js +8 -7
- package/esm/4_errors.js +2 -12
- package/esm/_dnt.polyfills.d.ts +99 -0
- package/esm/_dnt.polyfills.d.ts.map +1 -1
- package/esm/_dnt.polyfills.js +127 -1
- package/esm/_dnt.test_polyfills.d.ts.map +1 -0
- package/esm/client/0_filters_test.d.ts.map +1 -1
- package/esm/client/0_markdown_test.d.ts.map +1 -1
- package/esm/client/0_params.d.ts +2 -0
- package/esm/client/0_params.d.ts.map +1 -1
- package/esm/client/0_password.d.ts +5 -5
- package/esm/client/0_password.d.ts.map +1 -1
- package/esm/client/0_password_test.d.ts.map +1 -1
- package/esm/client/0_storage_operations.js +143 -155
- package/esm/client/0_storage_operations_test.d.ts.map +1 -1
- package/esm/client/0_utilities.d.ts +1 -1
- package/esm/client/0_utilities_test.d.ts.map +1 -1
- package/esm/client/1_client_plain.js +4 -22
- package/esm/client/1_composer.js +8 -21
- package/esm/client/2_account_manager.js +85 -97
- package/esm/client/2_bot_info_manager.js +26 -38
- package/esm/client/2_business_connection_manager.js +10 -23
- package/esm/client/2_client_encrypted.js +194 -211
- package/esm/client/2_file_manager.d.ts +4 -3
- package/esm/client/2_file_manager.d.ts.map +1 -1
- package/esm/client/2_file_manager.js +268 -224
- package/esm/client/2_file_manager_test.d.ts.map +1 -1
- package/esm/client/2_network_statistics_manager.js +8 -21
- package/esm/client/2_payment_manager.js +7 -20
- package/esm/client/2_reaction_manager.js +7 -20
- package/esm/client/2_translations_manager.js +97 -107
- package/esm/client/2_update_manager.js +764 -759
- package/esm/client/3_client_encrypted_pool.js +10 -26
- package/esm/client/3_client_encrypted_pool_test.d.ts.map +1 -1
- package/esm/client/3_message_manager.d.ts +1 -1
- package/esm/client/3_message_manager.js +441 -448
- package/esm/client/3_message_manager_test.d.ts.map +1 -1
- package/esm/client/3_video_chat_manager.d.ts +1 -1
- package/esm/client/3_video_chat_manager.js +57 -68
- package/esm/client/4_callback_query_manager.js +18 -30
- package/esm/client/4_chat_list_manager.js +322 -318
- package/esm/client/4_chat_manager.js +118 -131
- package/esm/client/4_forum_manager.js +67 -73
- package/esm/client/4_gift_manager.js +16 -29
- package/esm/client/4_inline_query_manager.js +16 -28
- package/esm/client/4_link_preview_manager.js +6 -19
- package/esm/client/4_poll_manager.js +44 -57
- package/esm/client/4_story_manager.js +41 -53
- package/esm/client/5_client.d.ts +7 -0
- package/esm/client/5_client.d.ts.map +1 -1
- package/esm/client/5_client.js +1271 -1290
- package/esm/connection/1_connection_tcp.node.js +48 -65
- package/esm/connection/1_connection_web_socket.js +75 -91
- package/esm/deps/jsr.io/@roj/tgcrypto/1.0.1/dist/tgcrypto.js +3 -11
- package/esm/deps/jsr.io/@std/assert/1.0.13/equals.js +4 -4
- package/esm/deps/jsr.io/@std/async/1.0.13/mux_async_iterator.js +31 -47
- package/esm/deps/jsr.io/@std/async/1.0.13/tee.js +11 -34
- package/esm/deps/jsr.io/@std/datetime/0.225.5/_date_time_formatter.js +4 -17
- package/esm/deps/jsr.io/@std/internal/1.0.10/build_message.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/internal/1.0.10/diff.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/internal/1.0.10/diff_str.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/internal/1.0.10/format.d.ts +29 -0
- package/esm/deps/jsr.io/@std/internal/1.0.10/format.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/internal/1.0.10/format.js +70 -0
- package/esm/deps/jsr.io/@std/internal/1.0.10/styles.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/internal/1.0.10/types.d.ts.map +1 -0
- package/esm/mod.js +2 -12
- package/esm/session/0_session_state.js +12 -38
- package/esm/session/1_session.js +49 -72
- package/esm/session/2_session_encrypted.js +324 -320
- package/esm/storage/1_utilities_test.d.ts.map +1 -1
- package/esm/storage/2_storage_indexed_db.js +26 -44
- package/esm/storage/2_storage_local_storage.node.js +12 -25
- package/esm/storage/2_storage_memory.js +24 -41
- package/esm/storage/2_storage_session_storage.js +3 -16
- package/esm/tl/0_utilities_test.d.ts.map +1 -1
- package/esm/tl/1_tl_reader.js +80 -88
- package/esm/tl/1_tl_reader_test.d.ts.map +1 -1
- package/esm/tl/1_tl_writer.js +155 -164
- package/esm/tl/1_tl_writer_test.d.ts.map +1 -1
- package/esm/tl/2_telegram.d.ts +9 -10
- package/esm/tl/2_telegram.d.ts.map +1 -1
- package/esm/tl/2_telegram.js +10 -10
- package/esm/transport/0_transport.js +1 -8
- package/esm/transport/1_transport_abridged.js +11 -24
- package/esm/transport/1_transport_intermediate.js +10 -23
- package/{script/transport/2_transport_provider.d.ts → esm/transport/1_transport_provider.d.ts} +1 -1
- package/esm/transport/{2_transport_provider.d.ts.map → 1_transport_provider.d.ts.map} +1 -1
- package/{script/transport/3_transport_provider_tcp.d.ts → esm/transport/2_transport_provider_tcp.d.ts} +2 -2
- package/esm/transport/{3_transport_provider_tcp.d.ts.map → 2_transport_provider_tcp.d.ts.map} +1 -1
- package/esm/transport/{3_transport_provider_tcp.js → 2_transport_provider_tcp.js} +1 -1
- package/esm/transport/{3_transport_provider_web_socket.d.ts → 2_transport_provider_web_socket.d.ts} +2 -2
- package/esm/transport/2_transport_provider_web_socket.d.ts.map +1 -0
- package/esm/transport/{3_transport_provider_web_socket.js → 2_transport_provider_web_socket.js} +1 -1
- package/esm/types/0_upload_progress.d.ts +29 -0
- package/esm/types/0_upload_progress.d.ts.map +1 -0
- package/esm/types/0_upload_progress.js +20 -0
- package/esm/types/{2_inline_keyboard_button.d.ts → 1_inline_keyboard_button.d.ts} +1 -1
- package/esm/types/{2_inline_keyboard_button.d.ts.map → 1_inline_keyboard_button.d.ts.map} +1 -1
- package/esm/types/1_sticker.d.ts +1 -1
- package/esm/types/1_sticker.d.ts.map +1 -1
- package/esm/types/2_chat.d.ts.map +1 -1
- package/esm/types/2_poll_answer.d.ts +19 -0
- package/esm/types/2_poll_answer.d.ts.map +1 -1
- package/esm/types/2_poll_answer.js +19 -0
- package/esm/types/2_pre_checkout_query.d.ts.map +1 -1
- package/esm/types/{3_reply_markup.d.ts → 2_reply_markup.d.ts} +2 -2
- package/esm/types/{3_reply_markup.d.ts.map → 2_reply_markup.d.ts.map} +1 -1
- package/esm/types/{3_reply_markup.js → 2_reply_markup.js} +1 -1
- package/esm/types/2_story_interactive_area.d.ts.map +1 -1
- package/esm/types/3_chat_member_updated.d.ts.map +1 -1
- package/esm/types/3_story.d.ts.map +1 -1
- package/esm/types/5_message.d.ts +1 -1
- package/esm/types/5_message.d.ts.map +1 -1
- package/esm/types/5_message.js +1 -1
- package/esm/types/6_inline_query_result.d.ts +1 -1
- package/esm/types/6_inline_query_result.js +1 -1
- package/esm/types/7_update.d.ts +21 -2
- package/esm/types/7_update.d.ts.map +1 -1
- package/esm/utilities/0_bigint_test.d.ts.map +1 -1
- package/esm/utilities/0_buffer.d.ts +1 -1
- package/esm/utilities/0_buffer.d.ts.map +1 -1
- package/esm/utilities/0_buffer_test.d.ts.map +1 -1
- package/esm/utilities/0_hash.d.ts +2 -2
- package/esm/utilities/0_hash.d.ts.map +1 -1
- package/esm/utilities/0_mutex.js +4 -19
- package/esm/utilities/0_part_stream.js +11 -25
- package/esm/utilities/0_part_stream_test.d.ts.map +1 -1
- package/esm/utilities/0_rle.d.ts +2 -2
- package/esm/utilities/0_rle.d.ts.map +1 -1
- package/esm/utilities/0_rle_test.d.ts.map +1 -1
- package/esm/utilities/0_text.d.ts +20 -1
- package/esm/utilities/0_text.d.ts.map +1 -1
- package/esm/utilities/0_text.js +19 -0
- package/esm/utilities/1_auth.d.ts +1 -1
- package/esm/utilities/1_auth.d.ts.map +1 -1
- package/esm/utilities/1_base64.d.ts +1 -1
- package/esm/utilities/1_base64.d.ts.map +1 -1
- package/esm/utilities/1_base64_test.d.ts.map +1 -1
- package/esm/utilities/1_crypto.js +42 -53
- package/esm/utilities/1_crypto_test.d.ts.map +1 -1
- package/esm/utilities/1_logger.d.ts +2 -2
- package/esm/utilities/1_math_test.d.ts.map +1 -1
- package/esm/utilities/2_queue.js +29 -47
- package/package.json +1 -1
- package/script/0_errors.js +2 -6
- package/script/2_tl.js +17 -7
- package/script/3_errors.js +2 -12
- package/script/3_transport.d.ts +3 -3
- package/script/3_transport.js +3 -3
- package/script/3_types.d.ts +8 -7
- package/script/3_types.d.ts.map +1 -1
- package/script/3_types.js +8 -7
- package/script/4_constants.js +17 -7
- package/script/4_errors.js +2 -12
- package/script/_dnt.polyfills.d.ts +99 -0
- package/script/_dnt.polyfills.d.ts.map +1 -1
- package/script/_dnt.polyfills.js +128 -0
- package/script/_dnt.test_polyfills.d.ts.map +1 -0
- package/script/client/0_filters_test.d.ts.map +1 -1
- package/script/client/0_markdown_test.d.ts.map +1 -1
- package/script/client/0_params.d.ts +2 -0
- package/script/client/0_params.d.ts.map +1 -1
- package/script/client/0_password.d.ts +5 -5
- package/script/client/0_password.d.ts.map +1 -1
- package/script/client/0_password.js +17 -7
- package/script/client/0_password_test.d.ts.map +1 -1
- package/script/client/0_storage_operations.js +143 -155
- package/script/client/0_storage_operations_test.d.ts.map +1 -1
- package/script/client/0_utilities.d.ts +1 -1
- package/script/client/0_utilities_test.d.ts.map +1 -1
- package/script/client/1_client_plain.js +4 -22
- package/script/client/1_composer.js +8 -21
- package/script/client/2_account_manager.js +85 -97
- package/script/client/2_bot_info_manager.js +26 -38
- package/script/client/2_business_connection_manager.js +10 -23
- package/script/client/2_client_encrypted.js +195 -212
- package/script/client/2_file_manager.d.ts +4 -3
- package/script/client/2_file_manager.d.ts.map +1 -1
- package/script/client/2_file_manager.js +285 -231
- package/script/client/2_file_manager_test.d.ts.map +1 -1
- package/script/client/2_network_statistics_manager.js +8 -21
- package/script/client/2_payment_manager.js +7 -20
- package/script/client/2_reaction_manager.js +7 -20
- package/script/client/2_translations_manager.js +98 -108
- package/script/client/2_update_manager.js +764 -759
- package/script/client/3_client_encrypted_pool.js +10 -26
- package/script/client/3_client_encrypted_pool_test.d.ts.map +1 -1
- package/script/client/3_message_manager.d.ts +1 -1
- package/script/client/3_message_manager.js +441 -448
- package/script/client/3_message_manager_test.d.ts.map +1 -1
- package/script/client/3_video_chat_manager.d.ts +1 -1
- package/script/client/3_video_chat_manager.js +57 -68
- package/script/client/4_callback_query_manager.js +18 -30
- package/script/client/4_chat_list_manager.js +322 -318
- package/script/client/4_chat_manager.js +118 -131
- package/script/client/4_forum_manager.js +67 -73
- package/script/client/4_gift_manager.js +16 -29
- package/script/client/4_inline_query_manager.js +16 -28
- package/script/client/4_link_preview_manager.js +6 -19
- package/script/client/4_poll_manager.js +44 -57
- package/script/client/4_story_manager.js +41 -53
- package/script/client/5_client.d.ts +7 -0
- package/script/client/5_client.d.ts.map +1 -1
- package/script/client/5_client.js +1271 -1290
- package/script/connection/1_connection_tcp.node.js +48 -65
- package/script/connection/1_connection_web_socket.js +92 -98
- package/script/deps/jsr.io/@roj/tgcrypto/1.0.1/dist/tgcrypto.js +3 -11
- package/script/deps/jsr.io/@std/assert/1.0.13/equal.js +17 -7
- package/script/deps/jsr.io/@std/assert/1.0.13/equals.js +4 -4
- package/script/deps/jsr.io/@std/async/1.0.13/delay.js +17 -7
- package/script/deps/jsr.io/@std/async/1.0.13/mux_async_iterator.js +31 -47
- package/script/deps/jsr.io/@std/async/1.0.13/tee.js +11 -34
- package/script/deps/jsr.io/@std/datetime/0.225.5/_date_time_formatter.js +4 -17
- package/script/deps/jsr.io/@std/internal/1.0.10/build_message.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/internal/1.0.10/diff.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/internal/1.0.10/diff_str.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/internal/1.0.10/format.d.ts +29 -0
- package/script/deps/jsr.io/@std/internal/1.0.10/format.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/internal/1.0.10/format.js +106 -0
- package/script/deps/jsr.io/@std/internal/1.0.10/styles.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/styles.js +17 -7
- package/script/deps/jsr.io/@std/internal/1.0.10/types.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/path/1.1.0/_os.js +17 -7
- package/script/mod.js +19 -19
- package/script/session/0_session_state.js +12 -38
- package/script/session/1_session.js +66 -79
- package/script/session/2_session_encrypted.js +325 -321
- package/script/storage/1_utilities_test.d.ts.map +1 -1
- package/script/storage/2_storage_indexed_db.js +26 -44
- package/script/storage/2_storage_local_storage.node.js +12 -25
- package/script/storage/2_storage_memory.js +24 -41
- package/script/storage/2_storage_session_storage.js +3 -16
- package/script/tl/0_utilities_test.d.ts.map +1 -1
- package/script/tl/1_tl_reader.js +81 -89
- package/script/tl/1_tl_reader_test.d.ts.map +1 -1
- package/script/tl/1_tl_writer.js +156 -165
- package/script/tl/1_tl_writer_test.d.ts.map +1 -1
- package/script/tl/2_telegram.d.ts +9 -10
- package/script/tl/2_telegram.d.ts.map +1 -1
- package/script/tl/2_telegram.js +32 -10
- package/script/transport/0_obfuscation.js +17 -7
- package/script/transport/0_transport.js +1 -8
- package/script/transport/1_transport_abridged.js +11 -24
- package/script/transport/1_transport_intermediate.js +10 -23
- package/{esm/transport/2_transport_provider.d.ts → script/transport/1_transport_provider.d.ts} +1 -1
- package/script/transport/{2_transport_provider.d.ts.map → 1_transport_provider.d.ts.map} +1 -1
- package/{esm/transport/3_transport_provider_tcp.d.ts → script/transport/2_transport_provider_tcp.d.ts} +2 -2
- package/script/transport/{3_transport_provider_tcp.d.ts.map → 2_transport_provider_tcp.d.ts.map} +1 -1
- package/script/transport/{3_transport_provider_tcp.js → 2_transport_provider_tcp.js} +3 -3
- package/script/transport/{3_transport_provider_web_socket.d.ts → 2_transport_provider_web_socket.d.ts} +2 -2
- package/script/transport/2_transport_provider_web_socket.d.ts.map +1 -0
- package/script/transport/{3_transport_provider_web_socket.js → 2_transport_provider_web_socket.js} +2 -2
- package/script/types/0_upload_progress.d.ts +29 -0
- package/script/types/0_upload_progress.d.ts.map +1 -0
- package/script/types/0_upload_progress.js +21 -0
- package/script/types/{2_inline_keyboard_button.d.ts → 1_inline_keyboard_button.d.ts} +1 -1
- package/script/types/{2_inline_keyboard_button.d.ts.map → 1_inline_keyboard_button.d.ts.map} +1 -1
- package/script/types/1_sticker.d.ts +1 -1
- package/script/types/1_sticker.d.ts.map +1 -1
- package/script/types/2_chat.d.ts.map +1 -1
- package/script/types/2_poll_answer.d.ts +19 -0
- package/script/types/2_poll_answer.d.ts.map +1 -1
- package/script/types/2_poll_answer.js +19 -0
- package/script/types/2_pre_checkout_query.d.ts.map +1 -1
- package/script/types/{3_reply_markup.d.ts → 2_reply_markup.d.ts} +2 -2
- package/script/types/{3_reply_markup.d.ts.map → 2_reply_markup.d.ts.map} +1 -1
- package/script/types/{3_reply_markup.js → 2_reply_markup.js} +3 -3
- package/script/types/2_story_interactive_area.d.ts.map +1 -1
- package/script/types/3_chat_member_updated.d.ts.map +1 -1
- package/script/types/3_story.d.ts.map +1 -1
- package/script/types/5_message.d.ts +1 -1
- package/script/types/5_message.d.ts.map +1 -1
- package/script/types/5_message.js +2 -2
- package/script/types/6_inline_query_result.d.ts +1 -1
- package/script/types/6_inline_query_result.js +4 -4
- package/script/types/7_update.d.ts +21 -2
- package/script/types/7_update.d.ts.map +1 -1
- package/script/utilities/0_bigint.js +17 -7
- package/script/utilities/0_bigint_test.d.ts.map +1 -1
- package/script/utilities/0_buffer.d.ts +1 -1
- package/script/utilities/0_buffer.d.ts.map +1 -1
- package/script/utilities/0_buffer_test.d.ts.map +1 -1
- package/script/utilities/0_env.js +17 -7
- package/script/utilities/0_hash.d.ts +2 -2
- package/script/utilities/0_hash.d.ts.map +1 -1
- package/script/utilities/0_hash.js +17 -7
- package/script/utilities/0_misc.js +17 -7
- package/script/utilities/0_mutex.js +4 -19
- package/script/utilities/0_part_stream.js +11 -25
- package/script/utilities/0_part_stream_test.d.ts.map +1 -1
- package/script/utilities/0_rle.d.ts +2 -2
- package/script/utilities/0_rle.d.ts.map +1 -1
- package/script/utilities/0_rle_test.d.ts.map +1 -1
- package/script/utilities/0_text.d.ts +20 -1
- package/script/utilities/0_text.d.ts.map +1 -1
- package/script/utilities/0_text.js +19 -0
- package/script/utilities/1_auth.d.ts +1 -1
- package/script/utilities/1_auth.d.ts.map +1 -1
- package/script/utilities/1_auth.js +17 -7
- package/script/utilities/1_base64.d.ts +1 -1
- package/script/utilities/1_base64.d.ts.map +1 -1
- package/script/utilities/1_base64_test.d.ts.map +1 -1
- package/script/utilities/1_crypto.js +60 -61
- package/script/utilities/1_crypto_test.d.ts.map +1 -1
- package/script/utilities/1_logger.d.ts +2 -2
- package/script/utilities/1_math_test.d.ts.map +1 -1
- package/script/utilities/2_queue.js +30 -48
- package/esm/deps/jsr.io/@std/internal/1.0.9/build_message.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/internal/1.0.9/diff.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/internal/1.0.9/diff_str.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/internal/1.0.9/format.d.ts +0 -2
- package/esm/deps/jsr.io/@std/internal/1.0.9/format.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/internal/1.0.9/format.js +0 -37
- package/esm/deps/jsr.io/@std/internal/1.0.9/styles.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/internal/1.0.9/types.d.ts.map +0 -1
- package/esm/transport/3_transport_provider_web_socket.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/internal/1.0.9/build_message.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/internal/1.0.9/diff.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/internal/1.0.9/diff_str.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/internal/1.0.9/format.d.ts +0 -2
- package/script/deps/jsr.io/@std/internal/1.0.9/format.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/internal/1.0.9/format.js +0 -63
- package/script/deps/jsr.io/@std/internal/1.0.9/styles.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/internal/1.0.9/types.d.ts.map +0 -1
- package/script/transport/3_transport_provider_web_socket.d.ts.map +0 -1
- /package/esm/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/build_message.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/build_message.js +0 -0
- /package/esm/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/diff.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/diff.js +0 -0
- /package/esm/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/diff_str.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/diff_str.js +0 -0
- /package/esm/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/styles.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/styles.js +0 -0
- /package/esm/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/types.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/types.js +0 -0
- /package/esm/transport/{2_transport_provider.js → 1_transport_provider.js} +0 -0
- /package/esm/types/{2_inline_keyboard_button.js → 1_inline_keyboard_button.js} +0 -0
- /package/script/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/build_message.d.ts +0 -0
- /package/script/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/build_message.js +0 -0
- /package/script/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/diff.d.ts +0 -0
- /package/script/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/diff.js +0 -0
- /package/script/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/diff_str.d.ts +0 -0
- /package/script/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/diff_str.js +0 -0
- /package/script/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/styles.d.ts +0 -0
- /package/script/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/types.d.ts +0 -0
- /package/script/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/types.js +0 -0
- /package/script/transport/{2_transport_provider.js → 1_transport_provider.js} +0 -0
- /package/script/types/{2_inline_keyboard_button.js → 1_inline_keyboard_button.js} +0 -0
|
@@ -18,18 +18,6 @@
|
|
|
18
18
|
* You should have received a copy of the GNU Lesser General Public License
|
|
19
19
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
20
20
|
*/
|
|
21
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
22
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
23
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
24
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
25
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
26
|
-
};
|
|
27
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
28
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
29
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
30
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
31
|
-
};
|
|
32
|
-
var _ChatListManager_instances, _ChatListManager_c, _ChatListManager_sendChatUpdate, _ChatListManager_chats, _ChatListManager_archivedChats, _ChatListManager_getChatAnywhere, _ChatListManager_getChatList, _ChatListManager_pinnedChats, _ChatListManager_pinnedArchiveChats, _ChatListManager_storageHadPinnedChats, _ChatListManager_pinnedChatsLoaded, _ChatListManager_loadPinnedChats, _ChatListManager_fetchPinnedChats, _ChatListManager_getPinnedChats, _ChatListManager_updateOrAddChat, _ChatListManager_removeChat, _ChatListManager_handleUpdateFolderPeers, _ChatListManager_handleUpdatePinnedDialogs, _ChatListManager_handleUpdateChannel, _ChatListManager_handleUpdateChat, _ChatListManager_handleUpdateUser, _ChatListManager_getFullChat, _ChatListManager_checkChatTitle, _ChatListManager_createChannel, _ChatListManager_moveChatsToFolder, _ChatListManager_toggleBusinessBotsPaused;
|
|
33
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
22
|
exports.ChatListManager = void 0;
|
|
35
23
|
const _0_deps_js_1 = require("../0_deps.js");
|
|
@@ -49,67 +37,71 @@ const chatListManagerUpdates = [
|
|
|
49
37
|
"updateUserName",
|
|
50
38
|
];
|
|
51
39
|
class ChatListManager {
|
|
40
|
+
#c;
|
|
52
41
|
constructor(c) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
42
|
+
this.#c = c;
|
|
43
|
+
}
|
|
44
|
+
#sendChatUpdate(chatId, added) {
|
|
45
|
+
try {
|
|
46
|
+
this.#c.storage.assertUser("");
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const [chat] = this.#getChatAnywhere(chatId);
|
|
52
|
+
const update = chat === undefined ? { deletedChat: { chatId } } : added ? { newChat: chat } : { editedChat: chat };
|
|
53
|
+
this.#c.handleUpdate(update);
|
|
62
54
|
}
|
|
63
55
|
async reassignChatLastMessage(chatId, add = false, sendUpdate = true) {
|
|
64
56
|
try {
|
|
65
|
-
|
|
57
|
+
this.#c.storage.assertUser("");
|
|
66
58
|
}
|
|
67
59
|
catch {
|
|
68
60
|
return () => Promise.resolve();
|
|
69
61
|
}
|
|
70
|
-
const [chat, listId] =
|
|
62
|
+
const [chat, listId] = this.#getChatAnywhere(chatId);
|
|
71
63
|
if (!chat && !add) {
|
|
72
64
|
return () => Promise.resolve();
|
|
73
65
|
}
|
|
74
|
-
const message_ = await
|
|
66
|
+
const message_ = await this.#c.messageStorage.getLastMessage(chatId);
|
|
75
67
|
if (message_ != null) {
|
|
76
|
-
const message = await
|
|
68
|
+
const message = await this.#c.messageManager.constructMessage(message_);
|
|
77
69
|
if (chat) {
|
|
78
70
|
chat.order = (0, _3_types_js_1.getChatListItemOrder)(message, chat.pinned);
|
|
79
71
|
chat.lastMessage = message;
|
|
80
|
-
await
|
|
72
|
+
await this.#c.storage.setChat(listId, chatId, chat.pinned, message.id, (0, _1_utilities_js_1.fromUnixTimestamp)(message.date));
|
|
81
73
|
}
|
|
82
74
|
else {
|
|
83
|
-
const pinnedChats = await
|
|
84
|
-
const chat = await (0, _3_types_js_1.constructChatListItem3)(chatId, pinnedChats.indexOf(chatId), message,
|
|
75
|
+
const pinnedChats = await this.#getPinnedChats(listId);
|
|
76
|
+
const chat = await (0, _3_types_js_1.constructChatListItem3)(chatId, pinnedChats.indexOf(chatId), message, this.#c.getEntity);
|
|
85
77
|
if (chat == null) {
|
|
86
78
|
(0, _0_deps_js_1.unreachable)();
|
|
87
79
|
}
|
|
88
|
-
|
|
89
|
-
await
|
|
80
|
+
this.#chats.set(chatId, chat);
|
|
81
|
+
await this.#c.storage.setChat(listId, chatId, chat.pinned, chat.lastMessage?.id ?? 0, (0, _1_utilities_js_1.fromUnixTimestamp)(chat.lastMessage?.date ?? 0));
|
|
90
82
|
}
|
|
91
83
|
if (sendUpdate) {
|
|
92
|
-
return () =>
|
|
84
|
+
return () => this.#sendChatUpdate(chatId, !chat);
|
|
93
85
|
}
|
|
94
86
|
return () => Promise.resolve();
|
|
95
87
|
}
|
|
96
|
-
const message = (await
|
|
88
|
+
const message = (await this.#c.messageManager.getHistory(chatId, { limit: 1 }))[0];
|
|
97
89
|
if (message) {
|
|
98
90
|
if (chat) {
|
|
99
91
|
chat.order = (0, _3_types_js_1.getChatListItemOrder)(message, chat.pinned);
|
|
100
92
|
chat.lastMessage = message;
|
|
101
|
-
await
|
|
93
|
+
await this.#c.storage.setChat(listId, chatId, chat.pinned, message.id, (0, _1_utilities_js_1.fromUnixTimestamp)(message.date));
|
|
102
94
|
}
|
|
103
95
|
else {
|
|
104
|
-
const pinnedChats = await
|
|
105
|
-
const chat = await (0, _3_types_js_1.constructChatListItem3)(chatId, pinnedChats.indexOf(chatId), message,
|
|
96
|
+
const pinnedChats = await this.#getPinnedChats(listId);
|
|
97
|
+
const chat = await (0, _3_types_js_1.constructChatListItem3)(chatId, pinnedChats.indexOf(chatId), message, this.#c.getEntity);
|
|
106
98
|
if (chat == null) {
|
|
107
99
|
(0, _0_deps_js_1.unreachable)();
|
|
108
100
|
}
|
|
109
|
-
|
|
101
|
+
this.#chats.set(chatId, chat);
|
|
110
102
|
}
|
|
111
103
|
if (sendUpdate) {
|
|
112
|
-
return () =>
|
|
104
|
+
return () => this.#sendChatUpdate(chatId, !chat);
|
|
113
105
|
}
|
|
114
106
|
return () => Promise.resolve();
|
|
115
107
|
}
|
|
@@ -117,33 +109,205 @@ class ChatListManager {
|
|
|
117
109
|
chat.order = (0, _3_types_js_1.getChatListItemOrder)(undefined, chat.pinned);
|
|
118
110
|
chat.lastMessage = undefined;
|
|
119
111
|
if (sendUpdate) {
|
|
120
|
-
return () =>
|
|
112
|
+
return () => this.#sendChatUpdate(chatId, false);
|
|
121
113
|
}
|
|
122
114
|
}
|
|
123
115
|
return () => Promise.resolve();
|
|
124
116
|
}
|
|
117
|
+
#chats = new Map();
|
|
118
|
+
#archivedChats = new Map();
|
|
119
|
+
#getChatAnywhere(chatId) {
|
|
120
|
+
let chat = this.#chats.get(chatId);
|
|
121
|
+
if (chat) {
|
|
122
|
+
return [chat, 0];
|
|
123
|
+
}
|
|
124
|
+
chat = this.#archivedChats.get(chatId);
|
|
125
|
+
if (chat) {
|
|
126
|
+
return [chat, 1];
|
|
127
|
+
}
|
|
128
|
+
return [undefined, -1];
|
|
129
|
+
}
|
|
130
|
+
#getChatList(listId) {
|
|
131
|
+
switch (listId) {
|
|
132
|
+
case 0:
|
|
133
|
+
return this.#chats;
|
|
134
|
+
case 1:
|
|
135
|
+
return this.#archivedChats;
|
|
136
|
+
default:
|
|
137
|
+
throw new Error(`Invalid chat list: ${listId}`);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
#pinnedChats = new Array();
|
|
141
|
+
#pinnedArchiveChats = new Array();
|
|
142
|
+
#storageHadPinnedChats = false;
|
|
143
|
+
#pinnedChatsLoaded = false;
|
|
144
|
+
async #loadPinnedChats() {
|
|
145
|
+
const [pinnedChats, pinnedArchiveChats] = await Promise.all([this.#c.storage.getPinnedChats(0), this.#c.storage.getPinnedChats(1)]);
|
|
146
|
+
if (pinnedChats != null && pinnedArchiveChats != null) {
|
|
147
|
+
this.#pinnedChats = pinnedChats;
|
|
148
|
+
this.#pinnedArchiveChats = pinnedArchiveChats;
|
|
149
|
+
this.#storageHadPinnedChats = true;
|
|
150
|
+
}
|
|
151
|
+
this.#pinnedChatsLoaded = true;
|
|
152
|
+
}
|
|
153
|
+
async #fetchPinnedChats(listId = null) {
|
|
154
|
+
if (listId == null || listId == 0) {
|
|
155
|
+
const dialogs = await this.#c.invoke({ _: "messages.getPinnedDialogs", folder_id: 0 });
|
|
156
|
+
const pinnedChats = new Array();
|
|
157
|
+
for (const dialog of dialogs.dialogs) {
|
|
158
|
+
pinnedChats.push(_2_tl_js_1.Api.peerToChatId(dialog.peer));
|
|
159
|
+
}
|
|
160
|
+
this.#pinnedChats = pinnedChats;
|
|
161
|
+
await this.#c.storage.setPinnedChats(0, this.#pinnedChats);
|
|
162
|
+
}
|
|
163
|
+
if (listId == null || listId == 1) {
|
|
164
|
+
const dialogs = await this.#c.invoke({ _: "messages.getPinnedDialogs", folder_id: 1 });
|
|
165
|
+
const pinnedArchiveChats = new Array();
|
|
166
|
+
for (const dialog of dialogs.dialogs) {
|
|
167
|
+
pinnedArchiveChats.push(_2_tl_js_1.Api.peerToChatId(dialog.peer));
|
|
168
|
+
}
|
|
169
|
+
this.#pinnedArchiveChats = pinnedArchiveChats;
|
|
170
|
+
await this.#c.storage.setPinnedChats(1, this.#pinnedArchiveChats);
|
|
171
|
+
}
|
|
172
|
+
if (listId != null && listId != 0 && listId != 1) {
|
|
173
|
+
(0, _0_deps_js_1.unreachable)();
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
async #getPinnedChats(listId) {
|
|
177
|
+
if (!this.#pinnedChatsLoaded) {
|
|
178
|
+
await this.#loadPinnedChats();
|
|
179
|
+
}
|
|
180
|
+
if (!this.#storageHadPinnedChats) {
|
|
181
|
+
await this.#fetchPinnedChats();
|
|
182
|
+
}
|
|
183
|
+
switch (listId) {
|
|
184
|
+
case 0:
|
|
185
|
+
return this.#pinnedChats;
|
|
186
|
+
case 1:
|
|
187
|
+
return this.#pinnedArchiveChats;
|
|
188
|
+
default:
|
|
189
|
+
(0, _0_deps_js_1.unreachable)();
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
async #updateOrAddChat(chatId) {
|
|
193
|
+
const [chat, listId] = this.#getChatAnywhere(chatId);
|
|
194
|
+
if (chat !== undefined) {
|
|
195
|
+
const newChat = await (0, _3_types_js_1.constructChatListItem3)(chatId, chat.pinned, chat.lastMessage, this.#c.getEntity);
|
|
196
|
+
if (newChat != null) {
|
|
197
|
+
this.#getChatList(listId).set(chatId, newChat);
|
|
198
|
+
this.#sendChatUpdate(chatId, false);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
const chat = await (0, _3_types_js_1.constructChatListItem)(chatId, -1, -1, this.#c.getEntity, this.#c.messageManager.getMessage.bind(this.#c.messageManager));
|
|
203
|
+
if (chat != null) {
|
|
204
|
+
this.#getChatList(0).set(chatId, chat);
|
|
205
|
+
await this.reassignChatLastMessage(chatId, false, false);
|
|
206
|
+
this.#sendChatUpdate(chatId, true);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
#removeChat(chatId) {
|
|
211
|
+
const [chat, listId] = this.#getChatAnywhere(chatId);
|
|
212
|
+
if (chat !== undefined) {
|
|
213
|
+
this.#getChatList(listId).delete(chatId);
|
|
214
|
+
this.#sendChatUpdate(chatId, false);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
#handleUpdateFolderPeers(update) {
|
|
218
|
+
for (const { peer, folder_id: listId } of update.folder_peers) {
|
|
219
|
+
const chatId = _2_tl_js_1.Api.peerToChatId(peer);
|
|
220
|
+
const [chat, currentListId] = this.#getChatAnywhere(chatId);
|
|
221
|
+
if (chat !== undefined && listId != currentListId) {
|
|
222
|
+
this.#getChatList(currentListId).delete(chatId);
|
|
223
|
+
this.#getChatList(listId).set(chatId, chat);
|
|
224
|
+
this.#sendChatUpdate(chatId, true);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
async #handleUpdatePinnedDialogs(update) {
|
|
229
|
+
const listId = update.folder_id ?? 0;
|
|
230
|
+
await this.#fetchPinnedChats(update.folder_id);
|
|
231
|
+
const chats = this.#getChatList(listId);
|
|
232
|
+
const pinnedChats = await this.#getPinnedChats(listId);
|
|
233
|
+
for (const [i, chatId] of pinnedChats.entries()) {
|
|
234
|
+
const chat = chats.get(chatId);
|
|
235
|
+
if (chat !== undefined) {
|
|
236
|
+
chat.order = (0, _3_types_js_1.getChatListItemOrder)(chat.lastMessage, i);
|
|
237
|
+
chat.pinned = i;
|
|
238
|
+
await this.#sendChatUpdate(chatId, false);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
for (const chat of chats.values()) {
|
|
242
|
+
if (chat.pinned != -1 && pinnedChats.indexOf(chat.chat.id) == -1) {
|
|
243
|
+
chat.order = (0, _3_types_js_1.getChatListItemOrder)(chat.lastMessage, -1);
|
|
244
|
+
chat.pinned = -1;
|
|
245
|
+
await this.#sendChatUpdate(chat.chat.id, false);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
await this.#c.storage.setPinnedChats(listId, await this.#getPinnedChats(listId));
|
|
249
|
+
}
|
|
250
|
+
async #handleUpdateChannel(update) {
|
|
251
|
+
const peer = { ...update, _: "peerChannel" };
|
|
252
|
+
const channel = await this.#c.getEntity(peer);
|
|
253
|
+
const chatId = _2_tl_js_1.Api.peerToChatId(peer);
|
|
254
|
+
await this.#c.storage.setFullChat(chatId, null);
|
|
255
|
+
if (channel != null && "left" in channel && channel.left) {
|
|
256
|
+
this.#removeChat(chatId);
|
|
257
|
+
}
|
|
258
|
+
else if (_2_tl_js_1.Api.is("channelForbidden", channel)) {
|
|
259
|
+
this.#removeChat(chatId);
|
|
260
|
+
}
|
|
261
|
+
else if (_2_tl_js_1.Api.is("channel", channel)) {
|
|
262
|
+
await this.#updateOrAddChat(chatId);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
async #handleUpdateChat(update) {
|
|
266
|
+
const peer = { ...update, _: "peerChat" };
|
|
267
|
+
const chat = await this.#c.getEntity(peer);
|
|
268
|
+
const chatId = _2_tl_js_1.Api.peerToChatId(peer);
|
|
269
|
+
await this.#c.storage.setFullChat(chatId, null);
|
|
270
|
+
if (chat != null && "left" in chat && chat.left) {
|
|
271
|
+
await this.#removeChat(chatId);
|
|
272
|
+
}
|
|
273
|
+
else if (_2_tl_js_1.Api.is("chatForbidden", chat)) {
|
|
274
|
+
await this.#removeChat(chatId);
|
|
275
|
+
}
|
|
276
|
+
else if (_2_tl_js_1.Api.is("chat", chat)) {
|
|
277
|
+
await this.#updateOrAddChat(chatId);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
async #handleUpdateUser(update) {
|
|
281
|
+
const peer = { ...update, _: "peerUser" };
|
|
282
|
+
const chat = await this.#c.getEntity(peer);
|
|
283
|
+
const chatId = _2_tl_js_1.Api.peerToChatId(peer);
|
|
284
|
+
await this.#c.storage.setFullChat(chatId, null);
|
|
285
|
+
if (chat != null) {
|
|
286
|
+
await this.#updateOrAddChat(chatId);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
125
289
|
async getChats(from = "main", after, limit = 100) {
|
|
126
|
-
|
|
127
|
-
if (after && !
|
|
290
|
+
this.#c.storage.assertUser("getChats");
|
|
291
|
+
if (after && !this.#chats.get(after.chat.id)) {
|
|
128
292
|
throw new _0_errors_js_1.InputError("Invalid after");
|
|
129
293
|
}
|
|
130
294
|
if (limit <= 0 || limit > 100) {
|
|
131
295
|
limit = 100;
|
|
132
296
|
}
|
|
133
297
|
const listId = (0, _0_utilities_js_1.getChatListId)(from);
|
|
134
|
-
const dialogs = await
|
|
135
|
-
const pinnedChats = await
|
|
298
|
+
const dialogs = await this.#c.invoke({ _: "messages.getDialogs", limit, offset_id: after?.lastMessage?.id ?? 0, offset_date: after?.lastMessage?.date ?? 0, offset_peer: after ? await this.#c.getInputPeer(after.chat.id) : { _: "inputPeerEmpty" }, hash: 0n, folder_id: listId });
|
|
299
|
+
const pinnedChats = await this.#getPinnedChats(listId);
|
|
136
300
|
if (!(_2_tl_js_1.Api.is("messages.dialogs", dialogs)) && !(_2_tl_js_1.Api.is("messages.dialogsSlice", dialogs))) {
|
|
137
301
|
(0, _0_deps_js_1.unreachable)();
|
|
138
302
|
}
|
|
139
303
|
if (dialogs.dialogs.length < limit) {
|
|
140
|
-
await
|
|
304
|
+
await this.#c.storage.setHasAllChats(listId, true);
|
|
141
305
|
}
|
|
142
306
|
const chats = new Array();
|
|
143
307
|
for (const dialog of dialogs.dialogs) {
|
|
144
|
-
const chat = await (0, _3_types_js_1.constructChatListItem4)(dialog, dialogs, pinnedChats,
|
|
308
|
+
const chat = await (0, _3_types_js_1.constructChatListItem4)(dialog, dialogs, pinnedChats, this.#c.getEntity, this.#c.messageManager.getMessage.bind(this.#c.messageManager), this.#c.fileManager.getStickerSetName.bind(this.#c.fileManager));
|
|
145
309
|
chats.push(chat);
|
|
146
|
-
await
|
|
310
|
+
await this.#c.storage.setChat(listId, chat.chat.id, chat.pinned, chat.lastMessage?.id ?? 0, (0, _1_utilities_js_1.fromUnixTimestamp)(chat.lastMessage?.date ?? 0));
|
|
147
311
|
}
|
|
148
312
|
return chats;
|
|
149
313
|
}
|
|
@@ -158,54 +322,76 @@ class ChatListManager {
|
|
|
158
322
|
}
|
|
159
323
|
}
|
|
160
324
|
else if (_2_tl_js_1.Api.is("updatePinnedDialogs", update)) {
|
|
161
|
-
await
|
|
325
|
+
await this.#handleUpdatePinnedDialogs(update);
|
|
162
326
|
}
|
|
163
327
|
else if (_2_tl_js_1.Api.is("updateFolderPeers", update)) {
|
|
164
|
-
|
|
328
|
+
this.#handleUpdateFolderPeers(update);
|
|
165
329
|
}
|
|
166
330
|
else if (_2_tl_js_1.Api.is("updateChannel", update)) {
|
|
167
|
-
await
|
|
331
|
+
await this.#handleUpdateChannel(update);
|
|
168
332
|
}
|
|
169
333
|
else if (_2_tl_js_1.Api.is("updateChat", update)) {
|
|
170
|
-
await
|
|
334
|
+
await this.#handleUpdateChat(update);
|
|
171
335
|
}
|
|
172
336
|
else if (_2_tl_js_1.Api.is("updateUser", update) || _2_tl_js_1.Api.is("updateUserName", update)) {
|
|
173
|
-
await
|
|
337
|
+
await this.#handleUpdateUser(update);
|
|
174
338
|
}
|
|
175
339
|
else {
|
|
176
340
|
(0, _0_deps_js_1.unreachable)();
|
|
177
341
|
}
|
|
178
342
|
return null;
|
|
179
343
|
}
|
|
344
|
+
async #getFullChat(chatId) {
|
|
345
|
+
const inputPeer = await this.#c.getInputPeer(chatId);
|
|
346
|
+
const chatId_ = await this.#c.getInputPeerChatId(inputPeer);
|
|
347
|
+
let fullChat = await this.#c.storage.getFullChat(chatId_);
|
|
348
|
+
if (fullChat != null) {
|
|
349
|
+
return fullChat;
|
|
350
|
+
}
|
|
351
|
+
if ((0, _0_utilities_js_1.canBeInputUser)(inputPeer)) {
|
|
352
|
+
fullChat = (await this.#c.invoke({ _: "users.getFullUser", id: (0, _0_utilities_js_1.toInputUser)(inputPeer) })).full_user;
|
|
353
|
+
}
|
|
354
|
+
else if (_2_tl_js_1.Api.is("inputPeerChat", inputPeer)) {
|
|
355
|
+
fullChat = (await this.#c.invoke({ ...inputPeer, _: "messages.getFullChat" })).full_chat;
|
|
356
|
+
}
|
|
357
|
+
else if ((0, _0_utilities_js_1.canBeInputChannel)(inputPeer)) {
|
|
358
|
+
fullChat = (await this.#c.invoke({ _: "channels.getFullChannel", channel: (0, _0_utilities_js_1.toInputChannel)(inputPeer) })).full_chat;
|
|
359
|
+
}
|
|
360
|
+
await this.#c.storage.setFullChat(chatId_, fullChat);
|
|
361
|
+
if (fullChat != null && "call" in fullChat && _2_tl_js_1.Api.is("inputGroupCall", fullChat.call)) {
|
|
362
|
+
await this.#c.storage.setGroupCallAccessHash(fullChat.call.id, fullChat.call.access_hash);
|
|
363
|
+
}
|
|
364
|
+
return fullChat;
|
|
365
|
+
}
|
|
180
366
|
async getChat(chatId) {
|
|
181
|
-
const fullChat = await
|
|
367
|
+
const fullChat = await this.#getFullChat(chatId);
|
|
182
368
|
if (fullChat == null) {
|
|
183
369
|
throw new _0_errors_js_1.InputError("Chat not found.");
|
|
184
370
|
}
|
|
185
|
-
return await (0, _3_types_js_1.constructChat)(fullChat,
|
|
371
|
+
return await (0, _3_types_js_1.constructChat)(fullChat, this.#c.getEntity);
|
|
186
372
|
}
|
|
187
373
|
async getChatAdministrators(chatId) {
|
|
188
|
-
const peer = await
|
|
374
|
+
const peer = await this.#c.getInputPeer(chatId);
|
|
189
375
|
if ((0, _0_utilities_js_1.canBeInputChannel)(peer)) {
|
|
190
376
|
const channel = (0, _0_utilities_js_1.toInputChannel)(peer);
|
|
191
|
-
const participants = await
|
|
377
|
+
const participants = await this.#c.invoke({ _: "channels.getParticipants", channel, filter: { _: "channelParticipantsAdmins" }, offset: 0, limit: 100, hash: 0n });
|
|
192
378
|
if (_2_tl_js_1.Api.is("channels.channelParticipantsNotModified", participants)) {
|
|
193
379
|
(0, _0_deps_js_1.unreachable)();
|
|
194
380
|
}
|
|
195
381
|
const chatMembers = new Array();
|
|
196
382
|
for (const p of participants.participants) {
|
|
197
|
-
chatMembers.push(await (0, _3_types_js_1.constructChatMember)(p,
|
|
383
|
+
chatMembers.push(await (0, _3_types_js_1.constructChatMember)(p, this.#c.getEntity));
|
|
198
384
|
}
|
|
199
385
|
return chatMembers;
|
|
200
386
|
}
|
|
201
387
|
else if (_2_tl_js_1.Api.is("inputPeerChat", peer)) {
|
|
202
|
-
const fullChat = await
|
|
388
|
+
const fullChat = await this.#getFullChat(chatId);
|
|
203
389
|
if (!fullChat || !("participants" in fullChat) || !_2_tl_js_1.Api.is("chatParticipants", fullChat.participants)) {
|
|
204
390
|
(0, _0_deps_js_1.unreachable)();
|
|
205
391
|
}
|
|
206
392
|
const chatMembers = new Array();
|
|
207
393
|
for (const p of fullChat.participants.participants) {
|
|
208
|
-
chatMembers.push(await (0, _3_types_js_1.constructChatMember)(p,
|
|
394
|
+
chatMembers.push(await (0, _3_types_js_1.constructChatMember)(p, this.#c.getEntity));
|
|
209
395
|
}
|
|
210
396
|
return chatMembers;
|
|
211
397
|
}
|
|
@@ -214,44 +400,44 @@ class ChatListManager {
|
|
|
214
400
|
}
|
|
215
401
|
}
|
|
216
402
|
async getChatMember(chatId, userId) {
|
|
217
|
-
const peer = await
|
|
403
|
+
const peer = await this.#c.getInputPeer(chatId);
|
|
218
404
|
if ((0, _0_utilities_js_1.canBeInputChannel)(peer)) {
|
|
219
|
-
const { participant } = await
|
|
220
|
-
return await (0, _3_types_js_1.constructChatMember)(participant,
|
|
405
|
+
const { participant } = await this.#c.invoke({ _: "channels.getParticipant", channel: (0, _0_utilities_js_1.toInputChannel)(peer), participant: await this.#c.getInputPeer(userId) });
|
|
406
|
+
return await (0, _3_types_js_1.constructChatMember)(participant, this.#c.getEntity);
|
|
221
407
|
}
|
|
222
408
|
else if (_2_tl_js_1.Api.is("inputPeerChat", peer)) {
|
|
223
|
-
const user = await
|
|
224
|
-
const userId_ = BigInt(await
|
|
225
|
-
const fullChat = await
|
|
409
|
+
const user = await this.#c.getInputUser(userId);
|
|
410
|
+
const userId_ = BigInt(await this.#c.getInputPeerChatId(user));
|
|
411
|
+
const fullChat = await this.#c.invoke({ ...peer, _: "messages.getFullChat" }).then((v) => _2_tl_js_1.Api.as("chatFull", v.full_chat));
|
|
226
412
|
const participant = _2_tl_js_1.Api.as("chatParticipants", fullChat.participants).participants.find((v) => v.user_id == userId_);
|
|
227
|
-
return await (0, _3_types_js_1.constructChatMember)(participant,
|
|
413
|
+
return await (0, _3_types_js_1.constructChatMember)(participant, this.#c.getEntity);
|
|
228
414
|
}
|
|
229
415
|
else {
|
|
230
416
|
throw new _0_errors_js_1.InputError("Expected a channel, supergroup, or group ID. Got a user ID instead.");
|
|
231
417
|
}
|
|
232
418
|
}
|
|
233
419
|
async getChatMembers(chatId, params) {
|
|
234
|
-
const peer = await
|
|
420
|
+
const peer = await this.#c.getInputPeer(chatId);
|
|
235
421
|
if ((0, _0_utilities_js_1.canBeInputChannel)(peer)) {
|
|
236
422
|
const channel = (0, _0_utilities_js_1.toInputChannel)(peer);
|
|
237
|
-
const participants = await
|
|
423
|
+
const participants = await this.#c.invoke({ _: "channels.getParticipants", channel, filter: { _: "channelParticipantsRecent" }, offset: params?.offset ?? 0, limit: (0, _0_utilities_js_1.getLimit)(params?.limit), hash: 0n });
|
|
238
424
|
if (_2_tl_js_1.Api.is("channels.channelParticipantsNotModified", participants)) {
|
|
239
425
|
(0, _0_deps_js_1.unreachable)();
|
|
240
426
|
}
|
|
241
427
|
const chatMembers = new Array();
|
|
242
428
|
for (const p of participants.participants) {
|
|
243
|
-
chatMembers.push(await (0, _3_types_js_1.constructChatMember)(p,
|
|
429
|
+
chatMembers.push(await (0, _3_types_js_1.constructChatMember)(p, this.#c.getEntity));
|
|
244
430
|
}
|
|
245
431
|
return chatMembers;
|
|
246
432
|
}
|
|
247
433
|
else if (_2_tl_js_1.Api.is("inputPeerChat", peer)) {
|
|
248
|
-
const fullChat = await
|
|
434
|
+
const fullChat = await this.#getFullChat(chatId);
|
|
249
435
|
if (!fullChat || !("participants" in fullChat) || !_2_tl_js_1.Api.is("chatParticipants", fullChat.participants)) {
|
|
250
436
|
(0, _0_deps_js_1.unreachable)();
|
|
251
437
|
}
|
|
252
438
|
const chatMembers = new Array();
|
|
253
439
|
for (const p of fullChat.participants.participants) {
|
|
254
|
-
chatMembers.push(await (0, _3_types_js_1.constructChatMember)(p,
|
|
440
|
+
chatMembers.push(await (0, _3_types_js_1.constructChatMember)(p, this.#c.getEntity));
|
|
255
441
|
}
|
|
256
442
|
return chatMembers;
|
|
257
443
|
}
|
|
@@ -259,13 +445,20 @@ class ChatListManager {
|
|
|
259
445
|
(0, _0_deps_js_1.unreachable)();
|
|
260
446
|
}
|
|
261
447
|
}
|
|
448
|
+
#checkChatTitle(title) {
|
|
449
|
+
title = title.trim();
|
|
450
|
+
if (!title) {
|
|
451
|
+
throw new _0_errors_js_1.InputError("Title cannot be empty.");
|
|
452
|
+
}
|
|
453
|
+
return title;
|
|
454
|
+
}
|
|
262
455
|
async createGroup(title, params) {
|
|
263
|
-
|
|
264
|
-
title =
|
|
265
|
-
const { updates } = await
|
|
456
|
+
this.#c.storage.assertUser("createGroup");
|
|
457
|
+
title = this.#checkChatTitle(title);
|
|
458
|
+
const { updates } = await this.#c.invoke({
|
|
266
459
|
_: "messages.createChat",
|
|
267
460
|
title,
|
|
268
|
-
users: await Promise.all((params?.users ?? []).map((v) =>
|
|
461
|
+
users: await Promise.all((params?.users ?? []).map((v) => this.#c.getInputUser(v))),
|
|
269
462
|
ttl_period: params?.messageTtl || undefined,
|
|
270
463
|
});
|
|
271
464
|
if (!("chats" in updates) || updates.chats.length < 1) {
|
|
@@ -277,45 +470,70 @@ class ChatListManager {
|
|
|
277
470
|
}
|
|
278
471
|
return (0, _3_types_js_1.constructChatP)(chat);
|
|
279
472
|
}
|
|
473
|
+
async #createChannel(type, title, params) {
|
|
474
|
+
title = this.#checkChatTitle(title);
|
|
475
|
+
const updates = await this.#c.invoke({
|
|
476
|
+
_: "channels.createChannel",
|
|
477
|
+
broadcast: type == "channel" ? true : undefined,
|
|
478
|
+
megagroup: type == "supergroup" ? true : undefined,
|
|
479
|
+
forum: params && ("forum" in params) && params.forum ? true : undefined,
|
|
480
|
+
title,
|
|
481
|
+
about: params?.description || "",
|
|
482
|
+
ttl_period: params?.messageTtl || undefined,
|
|
483
|
+
});
|
|
484
|
+
if (!("chats" in updates) || updates.chats.length < 1) {
|
|
485
|
+
(0, _0_deps_js_1.unreachable)();
|
|
486
|
+
}
|
|
487
|
+
const chat = updates.chats[0];
|
|
488
|
+
if (chat._ != "channel") {
|
|
489
|
+
(0, _0_deps_js_1.unreachable)();
|
|
490
|
+
}
|
|
491
|
+
return (0, _3_types_js_1.constructChatP)(chat);
|
|
492
|
+
}
|
|
280
493
|
async createSupergroup(title, params) {
|
|
281
|
-
|
|
282
|
-
return (await
|
|
494
|
+
this.#c.storage.assertUser("createSupergroup");
|
|
495
|
+
return (await this.#createChannel("supergroup", title, params));
|
|
283
496
|
}
|
|
284
497
|
async createChannel(title, params) {
|
|
285
|
-
|
|
286
|
-
return (await
|
|
498
|
+
this.#c.storage.assertUser("createChannel");
|
|
499
|
+
return (await this.#createChannel("channel", title, params));
|
|
287
500
|
}
|
|
288
501
|
async setMessageTtl(chatId, messageTtl) {
|
|
289
|
-
|
|
290
|
-
const peer = await
|
|
502
|
+
this.#c.storage.assertUser("setMessageTtl");
|
|
503
|
+
const peer = await this.#c.getInputPeer(chatId);
|
|
291
504
|
const period = messageTtl;
|
|
292
|
-
await
|
|
505
|
+
await this.#c.invoke({ _: "messages.setHistoryTTL", peer, period });
|
|
506
|
+
}
|
|
507
|
+
async #moveChatsToFolder(chatIds, folderId) {
|
|
508
|
+
const peers = await Promise.all(chatIds.map((v) => this.#c.getInputPeer(v)));
|
|
509
|
+
const inputFolderPeers = peers.map((v) => ({ _: "inputFolderPeer", peer: v, folder_id: folderId }));
|
|
510
|
+
await this.#c.invoke({ _: "folders.editPeerFolders", folder_peers: inputFolderPeers });
|
|
293
511
|
}
|
|
294
512
|
async archiveChats(chatIds) {
|
|
295
|
-
|
|
296
|
-
await
|
|
513
|
+
this.#c.storage.assertUser("archiveChats");
|
|
514
|
+
await this.#moveChatsToFolder(chatIds, 1);
|
|
297
515
|
}
|
|
298
516
|
async archiveChat(chatId) {
|
|
299
|
-
|
|
517
|
+
this.#c.storage.assertUser("archiveChat");
|
|
300
518
|
await this.archiveChats([chatId]);
|
|
301
519
|
}
|
|
302
520
|
async unarchiveChats(chatIds) {
|
|
303
|
-
|
|
304
|
-
await
|
|
521
|
+
this.#c.storage.assertUser("unarchiveChats");
|
|
522
|
+
await this.#moveChatsToFolder(chatIds, 0);
|
|
305
523
|
}
|
|
306
524
|
async unarchiveChat(chatId) {
|
|
307
|
-
|
|
525
|
+
this.#c.storage.assertUser("unarchiveChat");
|
|
308
526
|
await this.unarchiveChats([chatId]);
|
|
309
527
|
}
|
|
310
528
|
async getCommonChats(userId, params) {
|
|
311
|
-
|
|
312
|
-
const max_id = params?.fromChatId ? await
|
|
529
|
+
this.#c.storage.assertUser("getCommonChats");
|
|
530
|
+
const max_id = params?.fromChatId ? await this.#c.getInputPeerChatId(await this.#c.getInputPeer(params.fromChatId)) : 0;
|
|
313
531
|
if (max_id < 0) {
|
|
314
532
|
throw new _0_errors_js_1.InputError("fromChatId must be a chat identifier.");
|
|
315
533
|
}
|
|
316
|
-
const user_id = await
|
|
534
|
+
const user_id = await this.#c.getInputUser(userId);
|
|
317
535
|
const limit = (0, _0_utilities_js_1.getLimit)(params?.limit);
|
|
318
|
-
const result = await
|
|
536
|
+
const result = await this.#c.invoke({ _: "messages.getCommonChats", user_id, max_id: _2_tl_js_1.Api.chatIdToPeerId(max_id), limit });
|
|
319
537
|
const chats = new Array();
|
|
320
538
|
for (const chat of result.chats) {
|
|
321
539
|
if (!_2_tl_js_1.Api.is("chatEmpty", chat)) {
|
|
@@ -325,239 +543,25 @@ class ChatListManager {
|
|
|
325
543
|
return chats;
|
|
326
544
|
}
|
|
327
545
|
async getChatSettings(chatId) {
|
|
328
|
-
|
|
329
|
-
const peer = await
|
|
330
|
-
const settings = await
|
|
546
|
+
this.#c.storage.assertUser("getChatSettings");
|
|
547
|
+
const peer = await this.#c.getInputPeer(chatId);
|
|
548
|
+
const settings = await this.#c.invoke({ _: "messages.getPeerSettings", peer });
|
|
331
549
|
return (0, _3_types_js_1.constructChatSettings)(settings);
|
|
332
550
|
}
|
|
551
|
+
async #toggleBusinessBotsPaused(chatId, paused) {
|
|
552
|
+
const peer = await this.#c.getInputPeer(chatId);
|
|
553
|
+
if (!(0, _0_utilities_js_1.canBeInputUser)(peer)) {
|
|
554
|
+
throw new _0_errors_js_1.InputError("A private chat was expected.");
|
|
555
|
+
}
|
|
556
|
+
await this.#c.invoke({ _: "account.toggleConnectedBotPaused", peer, paused });
|
|
557
|
+
}
|
|
333
558
|
async disableBusinessBots(chatId) {
|
|
334
|
-
|
|
335
|
-
await
|
|
559
|
+
this.#c.storage.assertUser("disableBusinessBots");
|
|
560
|
+
await this.#toggleBusinessBotsPaused(chatId, true);
|
|
336
561
|
}
|
|
337
562
|
async enableBusinessBots(chatId) {
|
|
338
|
-
|
|
339
|
-
await
|
|
563
|
+
this.#c.storage.assertUser("enableBusinessBots");
|
|
564
|
+
await this.#toggleBusinessBotsPaused(chatId, false);
|
|
340
565
|
}
|
|
341
566
|
}
|
|
342
567
|
exports.ChatListManager = ChatListManager;
|
|
343
|
-
_ChatListManager_c = new WeakMap(), _ChatListManager_chats = new WeakMap(), _ChatListManager_archivedChats = new WeakMap(), _ChatListManager_pinnedChats = new WeakMap(), _ChatListManager_pinnedArchiveChats = new WeakMap(), _ChatListManager_storageHadPinnedChats = new WeakMap(), _ChatListManager_pinnedChatsLoaded = new WeakMap(), _ChatListManager_instances = new WeakSet(), _ChatListManager_sendChatUpdate = function _ChatListManager_sendChatUpdate(chatId, added) {
|
|
344
|
-
try {
|
|
345
|
-
__classPrivateFieldGet(this, _ChatListManager_c, "f").storage.assertUser("");
|
|
346
|
-
}
|
|
347
|
-
catch {
|
|
348
|
-
return;
|
|
349
|
-
}
|
|
350
|
-
const [chat] = __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_getChatAnywhere).call(this, chatId);
|
|
351
|
-
const update = chat === undefined ? { deletedChat: { chatId } } : added ? { newChat: chat } : { editedChat: chat };
|
|
352
|
-
__classPrivateFieldGet(this, _ChatListManager_c, "f").handleUpdate(update);
|
|
353
|
-
}, _ChatListManager_getChatAnywhere = function _ChatListManager_getChatAnywhere(chatId) {
|
|
354
|
-
let chat = __classPrivateFieldGet(this, _ChatListManager_chats, "f").get(chatId);
|
|
355
|
-
if (chat) {
|
|
356
|
-
return [chat, 0];
|
|
357
|
-
}
|
|
358
|
-
chat = __classPrivateFieldGet(this, _ChatListManager_archivedChats, "f").get(chatId);
|
|
359
|
-
if (chat) {
|
|
360
|
-
return [chat, 1];
|
|
361
|
-
}
|
|
362
|
-
return [undefined, -1];
|
|
363
|
-
}, _ChatListManager_getChatList = function _ChatListManager_getChatList(listId) {
|
|
364
|
-
switch (listId) {
|
|
365
|
-
case 0:
|
|
366
|
-
return __classPrivateFieldGet(this, _ChatListManager_chats, "f");
|
|
367
|
-
case 1:
|
|
368
|
-
return __classPrivateFieldGet(this, _ChatListManager_archivedChats, "f");
|
|
369
|
-
default:
|
|
370
|
-
throw new Error(`Invalid chat list: ${listId}`);
|
|
371
|
-
}
|
|
372
|
-
}, _ChatListManager_loadPinnedChats = async function _ChatListManager_loadPinnedChats() {
|
|
373
|
-
const [pinnedChats, pinnedArchiveChats] = await Promise.all([__classPrivateFieldGet(this, _ChatListManager_c, "f").storage.getPinnedChats(0), __classPrivateFieldGet(this, _ChatListManager_c, "f").storage.getPinnedChats(1)]);
|
|
374
|
-
if (pinnedChats != null && pinnedArchiveChats != null) {
|
|
375
|
-
__classPrivateFieldSet(this, _ChatListManager_pinnedChats, pinnedChats, "f");
|
|
376
|
-
__classPrivateFieldSet(this, _ChatListManager_pinnedArchiveChats, pinnedArchiveChats, "f");
|
|
377
|
-
__classPrivateFieldSet(this, _ChatListManager_storageHadPinnedChats, true, "f");
|
|
378
|
-
}
|
|
379
|
-
__classPrivateFieldSet(this, _ChatListManager_pinnedChatsLoaded, true, "f");
|
|
380
|
-
}, _ChatListManager_fetchPinnedChats = async function _ChatListManager_fetchPinnedChats(listId = null) {
|
|
381
|
-
if (listId == null || listId == 0) {
|
|
382
|
-
const dialogs = await __classPrivateFieldGet(this, _ChatListManager_c, "f").invoke({ _: "messages.getPinnedDialogs", folder_id: 0 });
|
|
383
|
-
const pinnedChats = new Array();
|
|
384
|
-
for (const dialog of dialogs.dialogs) {
|
|
385
|
-
pinnedChats.push(_2_tl_js_1.Api.peerToChatId(dialog.peer));
|
|
386
|
-
}
|
|
387
|
-
__classPrivateFieldSet(this, _ChatListManager_pinnedChats, pinnedChats, "f");
|
|
388
|
-
await __classPrivateFieldGet(this, _ChatListManager_c, "f").storage.setPinnedChats(0, __classPrivateFieldGet(this, _ChatListManager_pinnedChats, "f"));
|
|
389
|
-
}
|
|
390
|
-
if (listId == null || listId == 1) {
|
|
391
|
-
const dialogs = await __classPrivateFieldGet(this, _ChatListManager_c, "f").invoke({ _: "messages.getPinnedDialogs", folder_id: 1 });
|
|
392
|
-
const pinnedArchiveChats = new Array();
|
|
393
|
-
for (const dialog of dialogs.dialogs) {
|
|
394
|
-
pinnedArchiveChats.push(_2_tl_js_1.Api.peerToChatId(dialog.peer));
|
|
395
|
-
}
|
|
396
|
-
__classPrivateFieldSet(this, _ChatListManager_pinnedArchiveChats, pinnedArchiveChats, "f");
|
|
397
|
-
await __classPrivateFieldGet(this, _ChatListManager_c, "f").storage.setPinnedChats(1, __classPrivateFieldGet(this, _ChatListManager_pinnedArchiveChats, "f"));
|
|
398
|
-
}
|
|
399
|
-
if (listId != null && listId != 0 && listId != 1) {
|
|
400
|
-
(0, _0_deps_js_1.unreachable)();
|
|
401
|
-
}
|
|
402
|
-
}, _ChatListManager_getPinnedChats = async function _ChatListManager_getPinnedChats(listId) {
|
|
403
|
-
if (!__classPrivateFieldGet(this, _ChatListManager_pinnedChatsLoaded, "f")) {
|
|
404
|
-
await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_loadPinnedChats).call(this);
|
|
405
|
-
}
|
|
406
|
-
if (!__classPrivateFieldGet(this, _ChatListManager_storageHadPinnedChats, "f")) {
|
|
407
|
-
await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_fetchPinnedChats).call(this);
|
|
408
|
-
}
|
|
409
|
-
switch (listId) {
|
|
410
|
-
case 0:
|
|
411
|
-
return __classPrivateFieldGet(this, _ChatListManager_pinnedChats, "f");
|
|
412
|
-
case 1:
|
|
413
|
-
return __classPrivateFieldGet(this, _ChatListManager_pinnedArchiveChats, "f");
|
|
414
|
-
default:
|
|
415
|
-
(0, _0_deps_js_1.unreachable)();
|
|
416
|
-
}
|
|
417
|
-
}, _ChatListManager_updateOrAddChat = async function _ChatListManager_updateOrAddChat(chatId) {
|
|
418
|
-
const [chat, listId] = __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_getChatAnywhere).call(this, chatId);
|
|
419
|
-
if (chat !== undefined) {
|
|
420
|
-
const newChat = await (0, _3_types_js_1.constructChatListItem3)(chatId, chat.pinned, chat.lastMessage, __classPrivateFieldGet(this, _ChatListManager_c, "f").getEntity);
|
|
421
|
-
if (newChat != null) {
|
|
422
|
-
__classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_getChatList).call(this, listId).set(chatId, newChat);
|
|
423
|
-
__classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_sendChatUpdate).call(this, chatId, false);
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
else {
|
|
427
|
-
const chat = await (0, _3_types_js_1.constructChatListItem)(chatId, -1, -1, __classPrivateFieldGet(this, _ChatListManager_c, "f").getEntity, __classPrivateFieldGet(this, _ChatListManager_c, "f").messageManager.getMessage.bind(__classPrivateFieldGet(this, _ChatListManager_c, "f").messageManager));
|
|
428
|
-
if (chat != null) {
|
|
429
|
-
__classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_getChatList).call(this, 0).set(chatId, chat);
|
|
430
|
-
await this.reassignChatLastMessage(chatId, false, false);
|
|
431
|
-
__classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_sendChatUpdate).call(this, chatId, true);
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
}, _ChatListManager_removeChat = function _ChatListManager_removeChat(chatId) {
|
|
435
|
-
const [chat, listId] = __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_getChatAnywhere).call(this, chatId);
|
|
436
|
-
if (chat !== undefined) {
|
|
437
|
-
__classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_getChatList).call(this, listId).delete(chatId);
|
|
438
|
-
__classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_sendChatUpdate).call(this, chatId, false);
|
|
439
|
-
}
|
|
440
|
-
}, _ChatListManager_handleUpdateFolderPeers = function _ChatListManager_handleUpdateFolderPeers(update) {
|
|
441
|
-
for (const { peer, folder_id: listId } of update.folder_peers) {
|
|
442
|
-
const chatId = _2_tl_js_1.Api.peerToChatId(peer);
|
|
443
|
-
const [chat, currentListId] = __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_getChatAnywhere).call(this, chatId);
|
|
444
|
-
if (chat !== undefined && listId != currentListId) {
|
|
445
|
-
__classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_getChatList).call(this, currentListId).delete(chatId);
|
|
446
|
-
__classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_getChatList).call(this, listId).set(chatId, chat);
|
|
447
|
-
__classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_sendChatUpdate).call(this, chatId, true);
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
}, _ChatListManager_handleUpdatePinnedDialogs = async function _ChatListManager_handleUpdatePinnedDialogs(update) {
|
|
451
|
-
const listId = update.folder_id ?? 0;
|
|
452
|
-
await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_fetchPinnedChats).call(this, update.folder_id);
|
|
453
|
-
const chats = __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_getChatList).call(this, listId);
|
|
454
|
-
const pinnedChats = await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_getPinnedChats).call(this, listId);
|
|
455
|
-
for (const [i, chatId] of pinnedChats.entries()) {
|
|
456
|
-
const chat = chats.get(chatId);
|
|
457
|
-
if (chat !== undefined) {
|
|
458
|
-
chat.order = (0, _3_types_js_1.getChatListItemOrder)(chat.lastMessage, i);
|
|
459
|
-
chat.pinned = i;
|
|
460
|
-
await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_sendChatUpdate).call(this, chatId, false);
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
for (const chat of chats.values()) {
|
|
464
|
-
if (chat.pinned != -1 && pinnedChats.indexOf(chat.chat.id) == -1) {
|
|
465
|
-
chat.order = (0, _3_types_js_1.getChatListItemOrder)(chat.lastMessage, -1);
|
|
466
|
-
chat.pinned = -1;
|
|
467
|
-
await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_sendChatUpdate).call(this, chat.chat.id, false);
|
|
468
|
-
}
|
|
469
|
-
}
|
|
470
|
-
await __classPrivateFieldGet(this, _ChatListManager_c, "f").storage.setPinnedChats(listId, await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_getPinnedChats).call(this, listId));
|
|
471
|
-
}, _ChatListManager_handleUpdateChannel = async function _ChatListManager_handleUpdateChannel(update) {
|
|
472
|
-
const peer = { ...update, _: "peerChannel" };
|
|
473
|
-
const channel = await __classPrivateFieldGet(this, _ChatListManager_c, "f").getEntity(peer);
|
|
474
|
-
const chatId = _2_tl_js_1.Api.peerToChatId(peer);
|
|
475
|
-
await __classPrivateFieldGet(this, _ChatListManager_c, "f").storage.setFullChat(chatId, null);
|
|
476
|
-
if (channel != null && "left" in channel && channel.left) {
|
|
477
|
-
__classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_removeChat).call(this, chatId);
|
|
478
|
-
}
|
|
479
|
-
else if (_2_tl_js_1.Api.is("channelForbidden", channel)) {
|
|
480
|
-
__classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_removeChat).call(this, chatId);
|
|
481
|
-
}
|
|
482
|
-
else if (_2_tl_js_1.Api.is("channel", channel)) {
|
|
483
|
-
await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_updateOrAddChat).call(this, chatId);
|
|
484
|
-
}
|
|
485
|
-
}, _ChatListManager_handleUpdateChat = async function _ChatListManager_handleUpdateChat(update) {
|
|
486
|
-
const peer = { ...update, _: "peerChat" };
|
|
487
|
-
const chat = await __classPrivateFieldGet(this, _ChatListManager_c, "f").getEntity(peer);
|
|
488
|
-
const chatId = _2_tl_js_1.Api.peerToChatId(peer);
|
|
489
|
-
await __classPrivateFieldGet(this, _ChatListManager_c, "f").storage.setFullChat(chatId, null);
|
|
490
|
-
if (chat != null && "left" in chat && chat.left) {
|
|
491
|
-
await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_removeChat).call(this, chatId);
|
|
492
|
-
}
|
|
493
|
-
else if (_2_tl_js_1.Api.is("chatForbidden", chat)) {
|
|
494
|
-
await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_removeChat).call(this, chatId);
|
|
495
|
-
}
|
|
496
|
-
else if (_2_tl_js_1.Api.is("chat", chat)) {
|
|
497
|
-
await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_updateOrAddChat).call(this, chatId);
|
|
498
|
-
}
|
|
499
|
-
}, _ChatListManager_handleUpdateUser = async function _ChatListManager_handleUpdateUser(update) {
|
|
500
|
-
const peer = { ...update, _: "peerUser" };
|
|
501
|
-
const chat = await __classPrivateFieldGet(this, _ChatListManager_c, "f").getEntity(peer);
|
|
502
|
-
const chatId = _2_tl_js_1.Api.peerToChatId(peer);
|
|
503
|
-
await __classPrivateFieldGet(this, _ChatListManager_c, "f").storage.setFullChat(chatId, null);
|
|
504
|
-
if (chat != null) {
|
|
505
|
-
await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_updateOrAddChat).call(this, chatId);
|
|
506
|
-
}
|
|
507
|
-
}, _ChatListManager_getFullChat = async function _ChatListManager_getFullChat(chatId) {
|
|
508
|
-
const inputPeer = await __classPrivateFieldGet(this, _ChatListManager_c, "f").getInputPeer(chatId);
|
|
509
|
-
const chatId_ = await __classPrivateFieldGet(this, _ChatListManager_c, "f").getInputPeerChatId(inputPeer);
|
|
510
|
-
let fullChat = await __classPrivateFieldGet(this, _ChatListManager_c, "f").storage.getFullChat(chatId_);
|
|
511
|
-
if (fullChat != null) {
|
|
512
|
-
return fullChat;
|
|
513
|
-
}
|
|
514
|
-
if ((0, _0_utilities_js_1.canBeInputUser)(inputPeer)) {
|
|
515
|
-
fullChat = (await __classPrivateFieldGet(this, _ChatListManager_c, "f").invoke({ _: "users.getFullUser", id: (0, _0_utilities_js_1.toInputUser)(inputPeer) })).full_user;
|
|
516
|
-
}
|
|
517
|
-
else if (_2_tl_js_1.Api.is("inputPeerChat", inputPeer)) {
|
|
518
|
-
fullChat = (await __classPrivateFieldGet(this, _ChatListManager_c, "f").invoke({ ...inputPeer, _: "messages.getFullChat" })).full_chat;
|
|
519
|
-
}
|
|
520
|
-
else if ((0, _0_utilities_js_1.canBeInputChannel)(inputPeer)) {
|
|
521
|
-
fullChat = (await __classPrivateFieldGet(this, _ChatListManager_c, "f").invoke({ _: "channels.getFullChannel", channel: (0, _0_utilities_js_1.toInputChannel)(inputPeer) })).full_chat;
|
|
522
|
-
}
|
|
523
|
-
await __classPrivateFieldGet(this, _ChatListManager_c, "f").storage.setFullChat(chatId_, fullChat);
|
|
524
|
-
if (fullChat != null && "call" in fullChat && _2_tl_js_1.Api.is("inputGroupCall", fullChat.call)) {
|
|
525
|
-
await __classPrivateFieldGet(this, _ChatListManager_c, "f").storage.setGroupCallAccessHash(fullChat.call.id, fullChat.call.access_hash);
|
|
526
|
-
}
|
|
527
|
-
return fullChat;
|
|
528
|
-
}, _ChatListManager_checkChatTitle = function _ChatListManager_checkChatTitle(title) {
|
|
529
|
-
title = title.trim();
|
|
530
|
-
if (!title) {
|
|
531
|
-
throw new _0_errors_js_1.InputError("Title cannot be empty.");
|
|
532
|
-
}
|
|
533
|
-
return title;
|
|
534
|
-
}, _ChatListManager_createChannel = async function _ChatListManager_createChannel(type, title, params) {
|
|
535
|
-
title = __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_checkChatTitle).call(this, title);
|
|
536
|
-
const updates = await __classPrivateFieldGet(this, _ChatListManager_c, "f").invoke({
|
|
537
|
-
_: "channels.createChannel",
|
|
538
|
-
broadcast: type == "channel" ? true : undefined,
|
|
539
|
-
megagroup: type == "supergroup" ? true : undefined,
|
|
540
|
-
forum: params && ("forum" in params) && params.forum ? true : undefined,
|
|
541
|
-
title,
|
|
542
|
-
about: params?.description || "",
|
|
543
|
-
ttl_period: params?.messageTtl || undefined,
|
|
544
|
-
});
|
|
545
|
-
if (!("chats" in updates) || updates.chats.length < 1) {
|
|
546
|
-
(0, _0_deps_js_1.unreachable)();
|
|
547
|
-
}
|
|
548
|
-
const chat = updates.chats[0];
|
|
549
|
-
if (chat._ != "channel") {
|
|
550
|
-
(0, _0_deps_js_1.unreachable)();
|
|
551
|
-
}
|
|
552
|
-
return (0, _3_types_js_1.constructChatP)(chat);
|
|
553
|
-
}, _ChatListManager_moveChatsToFolder = async function _ChatListManager_moveChatsToFolder(chatIds, folderId) {
|
|
554
|
-
const peers = await Promise.all(chatIds.map((v) => __classPrivateFieldGet(this, _ChatListManager_c, "f").getInputPeer(v)));
|
|
555
|
-
const inputFolderPeers = peers.map((v) => ({ _: "inputFolderPeer", peer: v, folder_id: folderId }));
|
|
556
|
-
await __classPrivateFieldGet(this, _ChatListManager_c, "f").invoke({ _: "folders.editPeerFolders", folder_peers: inputFolderPeers });
|
|
557
|
-
}, _ChatListManager_toggleBusinessBotsPaused = async function _ChatListManager_toggleBusinessBotsPaused(chatId, paused) {
|
|
558
|
-
const peer = await __classPrivateFieldGet(this, _ChatListManager_c, "f").getInputPeer(chatId);
|
|
559
|
-
if (!(0, _0_utilities_js_1.canBeInputUser)(peer)) {
|
|
560
|
-
throw new _0_errors_js_1.InputError("A private chat was expected.");
|
|
561
|
-
}
|
|
562
|
-
await __classPrivateFieldGet(this, _ChatListManager_c, "f").invoke({ _: "account.toggleConnectedBotPaused", peer, paused });
|
|
563
|
-
};
|