@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
|
@@ -17,18 +17,6 @@
|
|
|
17
17
|
* You should have received a copy of the GNU Lesser General Public License
|
|
18
18
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
19
19
|
*/
|
|
20
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
21
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
22
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
23
|
-
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");
|
|
24
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
25
|
-
};
|
|
26
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
27
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
28
|
-
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");
|
|
29
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
30
|
-
};
|
|
31
|
-
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;
|
|
32
20
|
import { unreachable } from "../0_deps.js";
|
|
33
21
|
import { InputError } from "../0_errors.js";
|
|
34
22
|
import { fromUnixTimestamp } from "../1_utilities.js";
|
|
@@ -46,67 +34,71 @@ const chatListManagerUpdates = [
|
|
|
46
34
|
"updateUserName",
|
|
47
35
|
];
|
|
48
36
|
export class ChatListManager {
|
|
37
|
+
#c;
|
|
49
38
|
constructor(c) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
39
|
+
this.#c = c;
|
|
40
|
+
}
|
|
41
|
+
#sendChatUpdate(chatId, added) {
|
|
42
|
+
try {
|
|
43
|
+
this.#c.storage.assertUser("");
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const [chat] = this.#getChatAnywhere(chatId);
|
|
49
|
+
const update = chat === undefined ? { deletedChat: { chatId } } : added ? { newChat: chat } : { editedChat: chat };
|
|
50
|
+
this.#c.handleUpdate(update);
|
|
59
51
|
}
|
|
60
52
|
async reassignChatLastMessage(chatId, add = false, sendUpdate = true) {
|
|
61
53
|
try {
|
|
62
|
-
|
|
54
|
+
this.#c.storage.assertUser("");
|
|
63
55
|
}
|
|
64
56
|
catch {
|
|
65
57
|
return () => Promise.resolve();
|
|
66
58
|
}
|
|
67
|
-
const [chat, listId] =
|
|
59
|
+
const [chat, listId] = this.#getChatAnywhere(chatId);
|
|
68
60
|
if (!chat && !add) {
|
|
69
61
|
return () => Promise.resolve();
|
|
70
62
|
}
|
|
71
|
-
const message_ = await
|
|
63
|
+
const message_ = await this.#c.messageStorage.getLastMessage(chatId);
|
|
72
64
|
if (message_ != null) {
|
|
73
|
-
const message = await
|
|
65
|
+
const message = await this.#c.messageManager.constructMessage(message_);
|
|
74
66
|
if (chat) {
|
|
75
67
|
chat.order = getChatListItemOrder(message, chat.pinned);
|
|
76
68
|
chat.lastMessage = message;
|
|
77
|
-
await
|
|
69
|
+
await this.#c.storage.setChat(listId, chatId, chat.pinned, message.id, fromUnixTimestamp(message.date));
|
|
78
70
|
}
|
|
79
71
|
else {
|
|
80
|
-
const pinnedChats = await
|
|
81
|
-
const chat = await constructChatListItem3(chatId, pinnedChats.indexOf(chatId), message,
|
|
72
|
+
const pinnedChats = await this.#getPinnedChats(listId);
|
|
73
|
+
const chat = await constructChatListItem3(chatId, pinnedChats.indexOf(chatId), message, this.#c.getEntity);
|
|
82
74
|
if (chat == null) {
|
|
83
75
|
unreachable();
|
|
84
76
|
}
|
|
85
|
-
|
|
86
|
-
await
|
|
77
|
+
this.#chats.set(chatId, chat);
|
|
78
|
+
await this.#c.storage.setChat(listId, chatId, chat.pinned, chat.lastMessage?.id ?? 0, fromUnixTimestamp(chat.lastMessage?.date ?? 0));
|
|
87
79
|
}
|
|
88
80
|
if (sendUpdate) {
|
|
89
|
-
return () =>
|
|
81
|
+
return () => this.#sendChatUpdate(chatId, !chat);
|
|
90
82
|
}
|
|
91
83
|
return () => Promise.resolve();
|
|
92
84
|
}
|
|
93
|
-
const message = (await
|
|
85
|
+
const message = (await this.#c.messageManager.getHistory(chatId, { limit: 1 }))[0];
|
|
94
86
|
if (message) {
|
|
95
87
|
if (chat) {
|
|
96
88
|
chat.order = getChatListItemOrder(message, chat.pinned);
|
|
97
89
|
chat.lastMessage = message;
|
|
98
|
-
await
|
|
90
|
+
await this.#c.storage.setChat(listId, chatId, chat.pinned, message.id, fromUnixTimestamp(message.date));
|
|
99
91
|
}
|
|
100
92
|
else {
|
|
101
|
-
const pinnedChats = await
|
|
102
|
-
const chat = await constructChatListItem3(chatId, pinnedChats.indexOf(chatId), message,
|
|
93
|
+
const pinnedChats = await this.#getPinnedChats(listId);
|
|
94
|
+
const chat = await constructChatListItem3(chatId, pinnedChats.indexOf(chatId), message, this.#c.getEntity);
|
|
103
95
|
if (chat == null) {
|
|
104
96
|
unreachable();
|
|
105
97
|
}
|
|
106
|
-
|
|
98
|
+
this.#chats.set(chatId, chat);
|
|
107
99
|
}
|
|
108
100
|
if (sendUpdate) {
|
|
109
|
-
return () =>
|
|
101
|
+
return () => this.#sendChatUpdate(chatId, !chat);
|
|
110
102
|
}
|
|
111
103
|
return () => Promise.resolve();
|
|
112
104
|
}
|
|
@@ -114,33 +106,205 @@ export class ChatListManager {
|
|
|
114
106
|
chat.order = getChatListItemOrder(undefined, chat.pinned);
|
|
115
107
|
chat.lastMessage = undefined;
|
|
116
108
|
if (sendUpdate) {
|
|
117
|
-
return () =>
|
|
109
|
+
return () => this.#sendChatUpdate(chatId, false);
|
|
118
110
|
}
|
|
119
111
|
}
|
|
120
112
|
return () => Promise.resolve();
|
|
121
113
|
}
|
|
114
|
+
#chats = new Map();
|
|
115
|
+
#archivedChats = new Map();
|
|
116
|
+
#getChatAnywhere(chatId) {
|
|
117
|
+
let chat = this.#chats.get(chatId);
|
|
118
|
+
if (chat) {
|
|
119
|
+
return [chat, 0];
|
|
120
|
+
}
|
|
121
|
+
chat = this.#archivedChats.get(chatId);
|
|
122
|
+
if (chat) {
|
|
123
|
+
return [chat, 1];
|
|
124
|
+
}
|
|
125
|
+
return [undefined, -1];
|
|
126
|
+
}
|
|
127
|
+
#getChatList(listId) {
|
|
128
|
+
switch (listId) {
|
|
129
|
+
case 0:
|
|
130
|
+
return this.#chats;
|
|
131
|
+
case 1:
|
|
132
|
+
return this.#archivedChats;
|
|
133
|
+
default:
|
|
134
|
+
throw new Error(`Invalid chat list: ${listId}`);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
#pinnedChats = new Array();
|
|
138
|
+
#pinnedArchiveChats = new Array();
|
|
139
|
+
#storageHadPinnedChats = false;
|
|
140
|
+
#pinnedChatsLoaded = false;
|
|
141
|
+
async #loadPinnedChats() {
|
|
142
|
+
const [pinnedChats, pinnedArchiveChats] = await Promise.all([this.#c.storage.getPinnedChats(0), this.#c.storage.getPinnedChats(1)]);
|
|
143
|
+
if (pinnedChats != null && pinnedArchiveChats != null) {
|
|
144
|
+
this.#pinnedChats = pinnedChats;
|
|
145
|
+
this.#pinnedArchiveChats = pinnedArchiveChats;
|
|
146
|
+
this.#storageHadPinnedChats = true;
|
|
147
|
+
}
|
|
148
|
+
this.#pinnedChatsLoaded = true;
|
|
149
|
+
}
|
|
150
|
+
async #fetchPinnedChats(listId = null) {
|
|
151
|
+
if (listId == null || listId == 0) {
|
|
152
|
+
const dialogs = await this.#c.invoke({ _: "messages.getPinnedDialogs", folder_id: 0 });
|
|
153
|
+
const pinnedChats = new Array();
|
|
154
|
+
for (const dialog of dialogs.dialogs) {
|
|
155
|
+
pinnedChats.push(Api.peerToChatId(dialog.peer));
|
|
156
|
+
}
|
|
157
|
+
this.#pinnedChats = pinnedChats;
|
|
158
|
+
await this.#c.storage.setPinnedChats(0, this.#pinnedChats);
|
|
159
|
+
}
|
|
160
|
+
if (listId == null || listId == 1) {
|
|
161
|
+
const dialogs = await this.#c.invoke({ _: "messages.getPinnedDialogs", folder_id: 1 });
|
|
162
|
+
const pinnedArchiveChats = new Array();
|
|
163
|
+
for (const dialog of dialogs.dialogs) {
|
|
164
|
+
pinnedArchiveChats.push(Api.peerToChatId(dialog.peer));
|
|
165
|
+
}
|
|
166
|
+
this.#pinnedArchiveChats = pinnedArchiveChats;
|
|
167
|
+
await this.#c.storage.setPinnedChats(1, this.#pinnedArchiveChats);
|
|
168
|
+
}
|
|
169
|
+
if (listId != null && listId != 0 && listId != 1) {
|
|
170
|
+
unreachable();
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
async #getPinnedChats(listId) {
|
|
174
|
+
if (!this.#pinnedChatsLoaded) {
|
|
175
|
+
await this.#loadPinnedChats();
|
|
176
|
+
}
|
|
177
|
+
if (!this.#storageHadPinnedChats) {
|
|
178
|
+
await this.#fetchPinnedChats();
|
|
179
|
+
}
|
|
180
|
+
switch (listId) {
|
|
181
|
+
case 0:
|
|
182
|
+
return this.#pinnedChats;
|
|
183
|
+
case 1:
|
|
184
|
+
return this.#pinnedArchiveChats;
|
|
185
|
+
default:
|
|
186
|
+
unreachable();
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
async #updateOrAddChat(chatId) {
|
|
190
|
+
const [chat, listId] = this.#getChatAnywhere(chatId);
|
|
191
|
+
if (chat !== undefined) {
|
|
192
|
+
const newChat = await constructChatListItem3(chatId, chat.pinned, chat.lastMessage, this.#c.getEntity);
|
|
193
|
+
if (newChat != null) {
|
|
194
|
+
this.#getChatList(listId).set(chatId, newChat);
|
|
195
|
+
this.#sendChatUpdate(chatId, false);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
else {
|
|
199
|
+
const chat = await constructChatListItem(chatId, -1, -1, this.#c.getEntity, this.#c.messageManager.getMessage.bind(this.#c.messageManager));
|
|
200
|
+
if (chat != null) {
|
|
201
|
+
this.#getChatList(0).set(chatId, chat);
|
|
202
|
+
await this.reassignChatLastMessage(chatId, false, false);
|
|
203
|
+
this.#sendChatUpdate(chatId, true);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
#removeChat(chatId) {
|
|
208
|
+
const [chat, listId] = this.#getChatAnywhere(chatId);
|
|
209
|
+
if (chat !== undefined) {
|
|
210
|
+
this.#getChatList(listId).delete(chatId);
|
|
211
|
+
this.#sendChatUpdate(chatId, false);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
#handleUpdateFolderPeers(update) {
|
|
215
|
+
for (const { peer, folder_id: listId } of update.folder_peers) {
|
|
216
|
+
const chatId = Api.peerToChatId(peer);
|
|
217
|
+
const [chat, currentListId] = this.#getChatAnywhere(chatId);
|
|
218
|
+
if (chat !== undefined && listId != currentListId) {
|
|
219
|
+
this.#getChatList(currentListId).delete(chatId);
|
|
220
|
+
this.#getChatList(listId).set(chatId, chat);
|
|
221
|
+
this.#sendChatUpdate(chatId, true);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
async #handleUpdatePinnedDialogs(update) {
|
|
226
|
+
const listId = update.folder_id ?? 0;
|
|
227
|
+
await this.#fetchPinnedChats(update.folder_id);
|
|
228
|
+
const chats = this.#getChatList(listId);
|
|
229
|
+
const pinnedChats = await this.#getPinnedChats(listId);
|
|
230
|
+
for (const [i, chatId] of pinnedChats.entries()) {
|
|
231
|
+
const chat = chats.get(chatId);
|
|
232
|
+
if (chat !== undefined) {
|
|
233
|
+
chat.order = getChatListItemOrder(chat.lastMessage, i);
|
|
234
|
+
chat.pinned = i;
|
|
235
|
+
await this.#sendChatUpdate(chatId, false);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
for (const chat of chats.values()) {
|
|
239
|
+
if (chat.pinned != -1 && pinnedChats.indexOf(chat.chat.id) == -1) {
|
|
240
|
+
chat.order = getChatListItemOrder(chat.lastMessage, -1);
|
|
241
|
+
chat.pinned = -1;
|
|
242
|
+
await this.#sendChatUpdate(chat.chat.id, false);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
await this.#c.storage.setPinnedChats(listId, await this.#getPinnedChats(listId));
|
|
246
|
+
}
|
|
247
|
+
async #handleUpdateChannel(update) {
|
|
248
|
+
const peer = { ...update, _: "peerChannel" };
|
|
249
|
+
const channel = await this.#c.getEntity(peer);
|
|
250
|
+
const chatId = Api.peerToChatId(peer);
|
|
251
|
+
await this.#c.storage.setFullChat(chatId, null);
|
|
252
|
+
if (channel != null && "left" in channel && channel.left) {
|
|
253
|
+
this.#removeChat(chatId);
|
|
254
|
+
}
|
|
255
|
+
else if (Api.is("channelForbidden", channel)) {
|
|
256
|
+
this.#removeChat(chatId);
|
|
257
|
+
}
|
|
258
|
+
else if (Api.is("channel", channel)) {
|
|
259
|
+
await this.#updateOrAddChat(chatId);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
async #handleUpdateChat(update) {
|
|
263
|
+
const peer = { ...update, _: "peerChat" };
|
|
264
|
+
const chat = await this.#c.getEntity(peer);
|
|
265
|
+
const chatId = Api.peerToChatId(peer);
|
|
266
|
+
await this.#c.storage.setFullChat(chatId, null);
|
|
267
|
+
if (chat != null && "left" in chat && chat.left) {
|
|
268
|
+
await this.#removeChat(chatId);
|
|
269
|
+
}
|
|
270
|
+
else if (Api.is("chatForbidden", chat)) {
|
|
271
|
+
await this.#removeChat(chatId);
|
|
272
|
+
}
|
|
273
|
+
else if (Api.is("chat", chat)) {
|
|
274
|
+
await this.#updateOrAddChat(chatId);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
async #handleUpdateUser(update) {
|
|
278
|
+
const peer = { ...update, _: "peerUser" };
|
|
279
|
+
const chat = await this.#c.getEntity(peer);
|
|
280
|
+
const chatId = Api.peerToChatId(peer);
|
|
281
|
+
await this.#c.storage.setFullChat(chatId, null);
|
|
282
|
+
if (chat != null) {
|
|
283
|
+
await this.#updateOrAddChat(chatId);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
122
286
|
async getChats(from = "main", after, limit = 100) {
|
|
123
|
-
|
|
124
|
-
if (after && !
|
|
287
|
+
this.#c.storage.assertUser("getChats");
|
|
288
|
+
if (after && !this.#chats.get(after.chat.id)) {
|
|
125
289
|
throw new InputError("Invalid after");
|
|
126
290
|
}
|
|
127
291
|
if (limit <= 0 || limit > 100) {
|
|
128
292
|
limit = 100;
|
|
129
293
|
}
|
|
130
294
|
const listId = getChatListId(from);
|
|
131
|
-
const dialogs = await
|
|
132
|
-
const pinnedChats = await
|
|
295
|
+
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 });
|
|
296
|
+
const pinnedChats = await this.#getPinnedChats(listId);
|
|
133
297
|
if (!(Api.is("messages.dialogs", dialogs)) && !(Api.is("messages.dialogsSlice", dialogs))) {
|
|
134
298
|
unreachable();
|
|
135
299
|
}
|
|
136
300
|
if (dialogs.dialogs.length < limit) {
|
|
137
|
-
await
|
|
301
|
+
await this.#c.storage.setHasAllChats(listId, true);
|
|
138
302
|
}
|
|
139
303
|
const chats = new Array();
|
|
140
304
|
for (const dialog of dialogs.dialogs) {
|
|
141
|
-
const chat = await constructChatListItem4(dialog, dialogs, pinnedChats,
|
|
305
|
+
const chat = await constructChatListItem4(dialog, dialogs, pinnedChats, this.#c.getEntity, this.#c.messageManager.getMessage.bind(this.#c.messageManager), this.#c.fileManager.getStickerSetName.bind(this.#c.fileManager));
|
|
142
306
|
chats.push(chat);
|
|
143
|
-
await
|
|
307
|
+
await this.#c.storage.setChat(listId, chat.chat.id, chat.pinned, chat.lastMessage?.id ?? 0, fromUnixTimestamp(chat.lastMessage?.date ?? 0));
|
|
144
308
|
}
|
|
145
309
|
return chats;
|
|
146
310
|
}
|
|
@@ -155,54 +319,76 @@ export class ChatListManager {
|
|
|
155
319
|
}
|
|
156
320
|
}
|
|
157
321
|
else if (Api.is("updatePinnedDialogs", update)) {
|
|
158
|
-
await
|
|
322
|
+
await this.#handleUpdatePinnedDialogs(update);
|
|
159
323
|
}
|
|
160
324
|
else if (Api.is("updateFolderPeers", update)) {
|
|
161
|
-
|
|
325
|
+
this.#handleUpdateFolderPeers(update);
|
|
162
326
|
}
|
|
163
327
|
else if (Api.is("updateChannel", update)) {
|
|
164
|
-
await
|
|
328
|
+
await this.#handleUpdateChannel(update);
|
|
165
329
|
}
|
|
166
330
|
else if (Api.is("updateChat", update)) {
|
|
167
|
-
await
|
|
331
|
+
await this.#handleUpdateChat(update);
|
|
168
332
|
}
|
|
169
333
|
else if (Api.is("updateUser", update) || Api.is("updateUserName", update)) {
|
|
170
|
-
await
|
|
334
|
+
await this.#handleUpdateUser(update);
|
|
171
335
|
}
|
|
172
336
|
else {
|
|
173
337
|
unreachable();
|
|
174
338
|
}
|
|
175
339
|
return null;
|
|
176
340
|
}
|
|
341
|
+
async #getFullChat(chatId) {
|
|
342
|
+
const inputPeer = await this.#c.getInputPeer(chatId);
|
|
343
|
+
const chatId_ = await this.#c.getInputPeerChatId(inputPeer);
|
|
344
|
+
let fullChat = await this.#c.storage.getFullChat(chatId_);
|
|
345
|
+
if (fullChat != null) {
|
|
346
|
+
return fullChat;
|
|
347
|
+
}
|
|
348
|
+
if (canBeInputUser(inputPeer)) {
|
|
349
|
+
fullChat = (await this.#c.invoke({ _: "users.getFullUser", id: toInputUser(inputPeer) })).full_user;
|
|
350
|
+
}
|
|
351
|
+
else if (Api.is("inputPeerChat", inputPeer)) {
|
|
352
|
+
fullChat = (await this.#c.invoke({ ...inputPeer, _: "messages.getFullChat" })).full_chat;
|
|
353
|
+
}
|
|
354
|
+
else if (canBeInputChannel(inputPeer)) {
|
|
355
|
+
fullChat = (await this.#c.invoke({ _: "channels.getFullChannel", channel: toInputChannel(inputPeer) })).full_chat;
|
|
356
|
+
}
|
|
357
|
+
await this.#c.storage.setFullChat(chatId_, fullChat);
|
|
358
|
+
if (fullChat != null && "call" in fullChat && Api.is("inputGroupCall", fullChat.call)) {
|
|
359
|
+
await this.#c.storage.setGroupCallAccessHash(fullChat.call.id, fullChat.call.access_hash);
|
|
360
|
+
}
|
|
361
|
+
return fullChat;
|
|
362
|
+
}
|
|
177
363
|
async getChat(chatId) {
|
|
178
|
-
const fullChat = await
|
|
364
|
+
const fullChat = await this.#getFullChat(chatId);
|
|
179
365
|
if (fullChat == null) {
|
|
180
366
|
throw new InputError("Chat not found.");
|
|
181
367
|
}
|
|
182
|
-
return await constructChat(fullChat,
|
|
368
|
+
return await constructChat(fullChat, this.#c.getEntity);
|
|
183
369
|
}
|
|
184
370
|
async getChatAdministrators(chatId) {
|
|
185
|
-
const peer = await
|
|
371
|
+
const peer = await this.#c.getInputPeer(chatId);
|
|
186
372
|
if (canBeInputChannel(peer)) {
|
|
187
373
|
const channel = toInputChannel(peer);
|
|
188
|
-
const participants = await
|
|
374
|
+
const participants = await this.#c.invoke({ _: "channels.getParticipants", channel, filter: { _: "channelParticipantsAdmins" }, offset: 0, limit: 100, hash: 0n });
|
|
189
375
|
if (Api.is("channels.channelParticipantsNotModified", participants)) {
|
|
190
376
|
unreachable();
|
|
191
377
|
}
|
|
192
378
|
const chatMembers = new Array();
|
|
193
379
|
for (const p of participants.participants) {
|
|
194
|
-
chatMembers.push(await constructChatMember(p,
|
|
380
|
+
chatMembers.push(await constructChatMember(p, this.#c.getEntity));
|
|
195
381
|
}
|
|
196
382
|
return chatMembers;
|
|
197
383
|
}
|
|
198
384
|
else if (Api.is("inputPeerChat", peer)) {
|
|
199
|
-
const fullChat = await
|
|
385
|
+
const fullChat = await this.#getFullChat(chatId);
|
|
200
386
|
if (!fullChat || !("participants" in fullChat) || !Api.is("chatParticipants", fullChat.participants)) {
|
|
201
387
|
unreachable();
|
|
202
388
|
}
|
|
203
389
|
const chatMembers = new Array();
|
|
204
390
|
for (const p of fullChat.participants.participants) {
|
|
205
|
-
chatMembers.push(await constructChatMember(p,
|
|
391
|
+
chatMembers.push(await constructChatMember(p, this.#c.getEntity));
|
|
206
392
|
}
|
|
207
393
|
return chatMembers;
|
|
208
394
|
}
|
|
@@ -211,44 +397,44 @@ export class ChatListManager {
|
|
|
211
397
|
}
|
|
212
398
|
}
|
|
213
399
|
async getChatMember(chatId, userId) {
|
|
214
|
-
const peer = await
|
|
400
|
+
const peer = await this.#c.getInputPeer(chatId);
|
|
215
401
|
if (canBeInputChannel(peer)) {
|
|
216
|
-
const { participant } = await
|
|
217
|
-
return await constructChatMember(participant,
|
|
402
|
+
const { participant } = await this.#c.invoke({ _: "channels.getParticipant", channel: toInputChannel(peer), participant: await this.#c.getInputPeer(userId) });
|
|
403
|
+
return await constructChatMember(participant, this.#c.getEntity);
|
|
218
404
|
}
|
|
219
405
|
else if (Api.is("inputPeerChat", peer)) {
|
|
220
|
-
const user = await
|
|
221
|
-
const userId_ = BigInt(await
|
|
222
|
-
const fullChat = await
|
|
406
|
+
const user = await this.#c.getInputUser(userId);
|
|
407
|
+
const userId_ = BigInt(await this.#c.getInputPeerChatId(user));
|
|
408
|
+
const fullChat = await this.#c.invoke({ ...peer, _: "messages.getFullChat" }).then((v) => Api.as("chatFull", v.full_chat));
|
|
223
409
|
const participant = Api.as("chatParticipants", fullChat.participants).participants.find((v) => v.user_id == userId_);
|
|
224
|
-
return await constructChatMember(participant,
|
|
410
|
+
return await constructChatMember(participant, this.#c.getEntity);
|
|
225
411
|
}
|
|
226
412
|
else {
|
|
227
413
|
throw new InputError("Expected a channel, supergroup, or group ID. Got a user ID instead.");
|
|
228
414
|
}
|
|
229
415
|
}
|
|
230
416
|
async getChatMembers(chatId, params) {
|
|
231
|
-
const peer = await
|
|
417
|
+
const peer = await this.#c.getInputPeer(chatId);
|
|
232
418
|
if (canBeInputChannel(peer)) {
|
|
233
419
|
const channel = toInputChannel(peer);
|
|
234
|
-
const participants = await
|
|
420
|
+
const participants = await this.#c.invoke({ _: "channels.getParticipants", channel, filter: { _: "channelParticipantsRecent" }, offset: params?.offset ?? 0, limit: getLimit(params?.limit), hash: 0n });
|
|
235
421
|
if (Api.is("channels.channelParticipantsNotModified", participants)) {
|
|
236
422
|
unreachable();
|
|
237
423
|
}
|
|
238
424
|
const chatMembers = new Array();
|
|
239
425
|
for (const p of participants.participants) {
|
|
240
|
-
chatMembers.push(await constructChatMember(p,
|
|
426
|
+
chatMembers.push(await constructChatMember(p, this.#c.getEntity));
|
|
241
427
|
}
|
|
242
428
|
return chatMembers;
|
|
243
429
|
}
|
|
244
430
|
else if (Api.is("inputPeerChat", peer)) {
|
|
245
|
-
const fullChat = await
|
|
431
|
+
const fullChat = await this.#getFullChat(chatId);
|
|
246
432
|
if (!fullChat || !("participants" in fullChat) || !Api.is("chatParticipants", fullChat.participants)) {
|
|
247
433
|
unreachable();
|
|
248
434
|
}
|
|
249
435
|
const chatMembers = new Array();
|
|
250
436
|
for (const p of fullChat.participants.participants) {
|
|
251
|
-
chatMembers.push(await constructChatMember(p,
|
|
437
|
+
chatMembers.push(await constructChatMember(p, this.#c.getEntity));
|
|
252
438
|
}
|
|
253
439
|
return chatMembers;
|
|
254
440
|
}
|
|
@@ -256,13 +442,20 @@ export class ChatListManager {
|
|
|
256
442
|
unreachable();
|
|
257
443
|
}
|
|
258
444
|
}
|
|
445
|
+
#checkChatTitle(title) {
|
|
446
|
+
title = title.trim();
|
|
447
|
+
if (!title) {
|
|
448
|
+
throw new InputError("Title cannot be empty.");
|
|
449
|
+
}
|
|
450
|
+
return title;
|
|
451
|
+
}
|
|
259
452
|
async createGroup(title, params) {
|
|
260
|
-
|
|
261
|
-
title =
|
|
262
|
-
const { updates } = await
|
|
453
|
+
this.#c.storage.assertUser("createGroup");
|
|
454
|
+
title = this.#checkChatTitle(title);
|
|
455
|
+
const { updates } = await this.#c.invoke({
|
|
263
456
|
_: "messages.createChat",
|
|
264
457
|
title,
|
|
265
|
-
users: await Promise.all((params?.users ?? []).map((v) =>
|
|
458
|
+
users: await Promise.all((params?.users ?? []).map((v) => this.#c.getInputUser(v))),
|
|
266
459
|
ttl_period: params?.messageTtl || undefined,
|
|
267
460
|
});
|
|
268
461
|
if (!("chats" in updates) || updates.chats.length < 1) {
|
|
@@ -274,45 +467,70 @@ export class ChatListManager {
|
|
|
274
467
|
}
|
|
275
468
|
return constructChatP(chat);
|
|
276
469
|
}
|
|
470
|
+
async #createChannel(type, title, params) {
|
|
471
|
+
title = this.#checkChatTitle(title);
|
|
472
|
+
const updates = await this.#c.invoke({
|
|
473
|
+
_: "channels.createChannel",
|
|
474
|
+
broadcast: type == "channel" ? true : undefined,
|
|
475
|
+
megagroup: type == "supergroup" ? true : undefined,
|
|
476
|
+
forum: params && ("forum" in params) && params.forum ? true : undefined,
|
|
477
|
+
title,
|
|
478
|
+
about: params?.description || "",
|
|
479
|
+
ttl_period: params?.messageTtl || undefined,
|
|
480
|
+
});
|
|
481
|
+
if (!("chats" in updates) || updates.chats.length < 1) {
|
|
482
|
+
unreachable();
|
|
483
|
+
}
|
|
484
|
+
const chat = updates.chats[0];
|
|
485
|
+
if (chat._ != "channel") {
|
|
486
|
+
unreachable();
|
|
487
|
+
}
|
|
488
|
+
return constructChatP(chat);
|
|
489
|
+
}
|
|
277
490
|
async createSupergroup(title, params) {
|
|
278
|
-
|
|
279
|
-
return (await
|
|
491
|
+
this.#c.storage.assertUser("createSupergroup");
|
|
492
|
+
return (await this.#createChannel("supergroup", title, params));
|
|
280
493
|
}
|
|
281
494
|
async createChannel(title, params) {
|
|
282
|
-
|
|
283
|
-
return (await
|
|
495
|
+
this.#c.storage.assertUser("createChannel");
|
|
496
|
+
return (await this.#createChannel("channel", title, params));
|
|
284
497
|
}
|
|
285
498
|
async setMessageTtl(chatId, messageTtl) {
|
|
286
|
-
|
|
287
|
-
const peer = await
|
|
499
|
+
this.#c.storage.assertUser("setMessageTtl");
|
|
500
|
+
const peer = await this.#c.getInputPeer(chatId);
|
|
288
501
|
const period = messageTtl;
|
|
289
|
-
await
|
|
502
|
+
await this.#c.invoke({ _: "messages.setHistoryTTL", peer, period });
|
|
503
|
+
}
|
|
504
|
+
async #moveChatsToFolder(chatIds, folderId) {
|
|
505
|
+
const peers = await Promise.all(chatIds.map((v) => this.#c.getInputPeer(v)));
|
|
506
|
+
const inputFolderPeers = peers.map((v) => ({ _: "inputFolderPeer", peer: v, folder_id: folderId }));
|
|
507
|
+
await this.#c.invoke({ _: "folders.editPeerFolders", folder_peers: inputFolderPeers });
|
|
290
508
|
}
|
|
291
509
|
async archiveChats(chatIds) {
|
|
292
|
-
|
|
293
|
-
await
|
|
510
|
+
this.#c.storage.assertUser("archiveChats");
|
|
511
|
+
await this.#moveChatsToFolder(chatIds, 1);
|
|
294
512
|
}
|
|
295
513
|
async archiveChat(chatId) {
|
|
296
|
-
|
|
514
|
+
this.#c.storage.assertUser("archiveChat");
|
|
297
515
|
await this.archiveChats([chatId]);
|
|
298
516
|
}
|
|
299
517
|
async unarchiveChats(chatIds) {
|
|
300
|
-
|
|
301
|
-
await
|
|
518
|
+
this.#c.storage.assertUser("unarchiveChats");
|
|
519
|
+
await this.#moveChatsToFolder(chatIds, 0);
|
|
302
520
|
}
|
|
303
521
|
async unarchiveChat(chatId) {
|
|
304
|
-
|
|
522
|
+
this.#c.storage.assertUser("unarchiveChat");
|
|
305
523
|
await this.unarchiveChats([chatId]);
|
|
306
524
|
}
|
|
307
525
|
async getCommonChats(userId, params) {
|
|
308
|
-
|
|
309
|
-
const max_id = params?.fromChatId ? await
|
|
526
|
+
this.#c.storage.assertUser("getCommonChats");
|
|
527
|
+
const max_id = params?.fromChatId ? await this.#c.getInputPeerChatId(await this.#c.getInputPeer(params.fromChatId)) : 0;
|
|
310
528
|
if (max_id < 0) {
|
|
311
529
|
throw new InputError("fromChatId must be a chat identifier.");
|
|
312
530
|
}
|
|
313
|
-
const user_id = await
|
|
531
|
+
const user_id = await this.#c.getInputUser(userId);
|
|
314
532
|
const limit = getLimit(params?.limit);
|
|
315
|
-
const result = await
|
|
533
|
+
const result = await this.#c.invoke({ _: "messages.getCommonChats", user_id, max_id: Api.chatIdToPeerId(max_id), limit });
|
|
316
534
|
const chats = new Array();
|
|
317
535
|
for (const chat of result.chats) {
|
|
318
536
|
if (!Api.is("chatEmpty", chat)) {
|
|
@@ -322,238 +540,24 @@ export class ChatListManager {
|
|
|
322
540
|
return chats;
|
|
323
541
|
}
|
|
324
542
|
async getChatSettings(chatId) {
|
|
325
|
-
|
|
326
|
-
const peer = await
|
|
327
|
-
const settings = await
|
|
543
|
+
this.#c.storage.assertUser("getChatSettings");
|
|
544
|
+
const peer = await this.#c.getInputPeer(chatId);
|
|
545
|
+
const settings = await this.#c.invoke({ _: "messages.getPeerSettings", peer });
|
|
328
546
|
return constructChatSettings(settings);
|
|
329
547
|
}
|
|
548
|
+
async #toggleBusinessBotsPaused(chatId, paused) {
|
|
549
|
+
const peer = await this.#c.getInputPeer(chatId);
|
|
550
|
+
if (!canBeInputUser(peer)) {
|
|
551
|
+
throw new InputError("A private chat was expected.");
|
|
552
|
+
}
|
|
553
|
+
await this.#c.invoke({ _: "account.toggleConnectedBotPaused", peer, paused });
|
|
554
|
+
}
|
|
330
555
|
async disableBusinessBots(chatId) {
|
|
331
|
-
|
|
332
|
-
await
|
|
556
|
+
this.#c.storage.assertUser("disableBusinessBots");
|
|
557
|
+
await this.#toggleBusinessBotsPaused(chatId, true);
|
|
333
558
|
}
|
|
334
559
|
async enableBusinessBots(chatId) {
|
|
335
|
-
|
|
336
|
-
await
|
|
560
|
+
this.#c.storage.assertUser("enableBusinessBots");
|
|
561
|
+
await this.#toggleBusinessBotsPaused(chatId, false);
|
|
337
562
|
}
|
|
338
563
|
}
|
|
339
|
-
_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) {
|
|
340
|
-
try {
|
|
341
|
-
__classPrivateFieldGet(this, _ChatListManager_c, "f").storage.assertUser("");
|
|
342
|
-
}
|
|
343
|
-
catch {
|
|
344
|
-
return;
|
|
345
|
-
}
|
|
346
|
-
const [chat] = __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_getChatAnywhere).call(this, chatId);
|
|
347
|
-
const update = chat === undefined ? { deletedChat: { chatId } } : added ? { newChat: chat } : { editedChat: chat };
|
|
348
|
-
__classPrivateFieldGet(this, _ChatListManager_c, "f").handleUpdate(update);
|
|
349
|
-
}, _ChatListManager_getChatAnywhere = function _ChatListManager_getChatAnywhere(chatId) {
|
|
350
|
-
let chat = __classPrivateFieldGet(this, _ChatListManager_chats, "f").get(chatId);
|
|
351
|
-
if (chat) {
|
|
352
|
-
return [chat, 0];
|
|
353
|
-
}
|
|
354
|
-
chat = __classPrivateFieldGet(this, _ChatListManager_archivedChats, "f").get(chatId);
|
|
355
|
-
if (chat) {
|
|
356
|
-
return [chat, 1];
|
|
357
|
-
}
|
|
358
|
-
return [undefined, -1];
|
|
359
|
-
}, _ChatListManager_getChatList = function _ChatListManager_getChatList(listId) {
|
|
360
|
-
switch (listId) {
|
|
361
|
-
case 0:
|
|
362
|
-
return __classPrivateFieldGet(this, _ChatListManager_chats, "f");
|
|
363
|
-
case 1:
|
|
364
|
-
return __classPrivateFieldGet(this, _ChatListManager_archivedChats, "f");
|
|
365
|
-
default:
|
|
366
|
-
throw new Error(`Invalid chat list: ${listId}`);
|
|
367
|
-
}
|
|
368
|
-
}, _ChatListManager_loadPinnedChats = async function _ChatListManager_loadPinnedChats() {
|
|
369
|
-
const [pinnedChats, pinnedArchiveChats] = await Promise.all([__classPrivateFieldGet(this, _ChatListManager_c, "f").storage.getPinnedChats(0), __classPrivateFieldGet(this, _ChatListManager_c, "f").storage.getPinnedChats(1)]);
|
|
370
|
-
if (pinnedChats != null && pinnedArchiveChats != null) {
|
|
371
|
-
__classPrivateFieldSet(this, _ChatListManager_pinnedChats, pinnedChats, "f");
|
|
372
|
-
__classPrivateFieldSet(this, _ChatListManager_pinnedArchiveChats, pinnedArchiveChats, "f");
|
|
373
|
-
__classPrivateFieldSet(this, _ChatListManager_storageHadPinnedChats, true, "f");
|
|
374
|
-
}
|
|
375
|
-
__classPrivateFieldSet(this, _ChatListManager_pinnedChatsLoaded, true, "f");
|
|
376
|
-
}, _ChatListManager_fetchPinnedChats = async function _ChatListManager_fetchPinnedChats(listId = null) {
|
|
377
|
-
if (listId == null || listId == 0) {
|
|
378
|
-
const dialogs = await __classPrivateFieldGet(this, _ChatListManager_c, "f").invoke({ _: "messages.getPinnedDialogs", folder_id: 0 });
|
|
379
|
-
const pinnedChats = new Array();
|
|
380
|
-
for (const dialog of dialogs.dialogs) {
|
|
381
|
-
pinnedChats.push(Api.peerToChatId(dialog.peer));
|
|
382
|
-
}
|
|
383
|
-
__classPrivateFieldSet(this, _ChatListManager_pinnedChats, pinnedChats, "f");
|
|
384
|
-
await __classPrivateFieldGet(this, _ChatListManager_c, "f").storage.setPinnedChats(0, __classPrivateFieldGet(this, _ChatListManager_pinnedChats, "f"));
|
|
385
|
-
}
|
|
386
|
-
if (listId == null || listId == 1) {
|
|
387
|
-
const dialogs = await __classPrivateFieldGet(this, _ChatListManager_c, "f").invoke({ _: "messages.getPinnedDialogs", folder_id: 1 });
|
|
388
|
-
const pinnedArchiveChats = new Array();
|
|
389
|
-
for (const dialog of dialogs.dialogs) {
|
|
390
|
-
pinnedArchiveChats.push(Api.peerToChatId(dialog.peer));
|
|
391
|
-
}
|
|
392
|
-
__classPrivateFieldSet(this, _ChatListManager_pinnedArchiveChats, pinnedArchiveChats, "f");
|
|
393
|
-
await __classPrivateFieldGet(this, _ChatListManager_c, "f").storage.setPinnedChats(1, __classPrivateFieldGet(this, _ChatListManager_pinnedArchiveChats, "f"));
|
|
394
|
-
}
|
|
395
|
-
if (listId != null && listId != 0 && listId != 1) {
|
|
396
|
-
unreachable();
|
|
397
|
-
}
|
|
398
|
-
}, _ChatListManager_getPinnedChats = async function _ChatListManager_getPinnedChats(listId) {
|
|
399
|
-
if (!__classPrivateFieldGet(this, _ChatListManager_pinnedChatsLoaded, "f")) {
|
|
400
|
-
await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_loadPinnedChats).call(this);
|
|
401
|
-
}
|
|
402
|
-
if (!__classPrivateFieldGet(this, _ChatListManager_storageHadPinnedChats, "f")) {
|
|
403
|
-
await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_fetchPinnedChats).call(this);
|
|
404
|
-
}
|
|
405
|
-
switch (listId) {
|
|
406
|
-
case 0:
|
|
407
|
-
return __classPrivateFieldGet(this, _ChatListManager_pinnedChats, "f");
|
|
408
|
-
case 1:
|
|
409
|
-
return __classPrivateFieldGet(this, _ChatListManager_pinnedArchiveChats, "f");
|
|
410
|
-
default:
|
|
411
|
-
unreachable();
|
|
412
|
-
}
|
|
413
|
-
}, _ChatListManager_updateOrAddChat = async function _ChatListManager_updateOrAddChat(chatId) {
|
|
414
|
-
const [chat, listId] = __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_getChatAnywhere).call(this, chatId);
|
|
415
|
-
if (chat !== undefined) {
|
|
416
|
-
const newChat = await constructChatListItem3(chatId, chat.pinned, chat.lastMessage, __classPrivateFieldGet(this, _ChatListManager_c, "f").getEntity);
|
|
417
|
-
if (newChat != null) {
|
|
418
|
-
__classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_getChatList).call(this, listId).set(chatId, newChat);
|
|
419
|
-
__classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_sendChatUpdate).call(this, chatId, false);
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
else {
|
|
423
|
-
const chat = await constructChatListItem(chatId, -1, -1, __classPrivateFieldGet(this, _ChatListManager_c, "f").getEntity, __classPrivateFieldGet(this, _ChatListManager_c, "f").messageManager.getMessage.bind(__classPrivateFieldGet(this, _ChatListManager_c, "f").messageManager));
|
|
424
|
-
if (chat != null) {
|
|
425
|
-
__classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_getChatList).call(this, 0).set(chatId, chat);
|
|
426
|
-
await this.reassignChatLastMessage(chatId, false, false);
|
|
427
|
-
__classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_sendChatUpdate).call(this, chatId, true);
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
}, _ChatListManager_removeChat = function _ChatListManager_removeChat(chatId) {
|
|
431
|
-
const [chat, listId] = __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_getChatAnywhere).call(this, chatId);
|
|
432
|
-
if (chat !== undefined) {
|
|
433
|
-
__classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_getChatList).call(this, listId).delete(chatId);
|
|
434
|
-
__classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_sendChatUpdate).call(this, chatId, false);
|
|
435
|
-
}
|
|
436
|
-
}, _ChatListManager_handleUpdateFolderPeers = function _ChatListManager_handleUpdateFolderPeers(update) {
|
|
437
|
-
for (const { peer, folder_id: listId } of update.folder_peers) {
|
|
438
|
-
const chatId = Api.peerToChatId(peer);
|
|
439
|
-
const [chat, currentListId] = __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_getChatAnywhere).call(this, chatId);
|
|
440
|
-
if (chat !== undefined && listId != currentListId) {
|
|
441
|
-
__classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_getChatList).call(this, currentListId).delete(chatId);
|
|
442
|
-
__classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_getChatList).call(this, listId).set(chatId, chat);
|
|
443
|
-
__classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_sendChatUpdate).call(this, chatId, true);
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
|
-
}, _ChatListManager_handleUpdatePinnedDialogs = async function _ChatListManager_handleUpdatePinnedDialogs(update) {
|
|
447
|
-
const listId = update.folder_id ?? 0;
|
|
448
|
-
await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_fetchPinnedChats).call(this, update.folder_id);
|
|
449
|
-
const chats = __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_getChatList).call(this, listId);
|
|
450
|
-
const pinnedChats = await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_getPinnedChats).call(this, listId);
|
|
451
|
-
for (const [i, chatId] of pinnedChats.entries()) {
|
|
452
|
-
const chat = chats.get(chatId);
|
|
453
|
-
if (chat !== undefined) {
|
|
454
|
-
chat.order = getChatListItemOrder(chat.lastMessage, i);
|
|
455
|
-
chat.pinned = i;
|
|
456
|
-
await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_sendChatUpdate).call(this, chatId, false);
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
for (const chat of chats.values()) {
|
|
460
|
-
if (chat.pinned != -1 && pinnedChats.indexOf(chat.chat.id) == -1) {
|
|
461
|
-
chat.order = getChatListItemOrder(chat.lastMessage, -1);
|
|
462
|
-
chat.pinned = -1;
|
|
463
|
-
await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_sendChatUpdate).call(this, chat.chat.id, false);
|
|
464
|
-
}
|
|
465
|
-
}
|
|
466
|
-
await __classPrivateFieldGet(this, _ChatListManager_c, "f").storage.setPinnedChats(listId, await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_getPinnedChats).call(this, listId));
|
|
467
|
-
}, _ChatListManager_handleUpdateChannel = async function _ChatListManager_handleUpdateChannel(update) {
|
|
468
|
-
const peer = { ...update, _: "peerChannel" };
|
|
469
|
-
const channel = await __classPrivateFieldGet(this, _ChatListManager_c, "f").getEntity(peer);
|
|
470
|
-
const chatId = Api.peerToChatId(peer);
|
|
471
|
-
await __classPrivateFieldGet(this, _ChatListManager_c, "f").storage.setFullChat(chatId, null);
|
|
472
|
-
if (channel != null && "left" in channel && channel.left) {
|
|
473
|
-
__classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_removeChat).call(this, chatId);
|
|
474
|
-
}
|
|
475
|
-
else if (Api.is("channelForbidden", channel)) {
|
|
476
|
-
__classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_removeChat).call(this, chatId);
|
|
477
|
-
}
|
|
478
|
-
else if (Api.is("channel", channel)) {
|
|
479
|
-
await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_updateOrAddChat).call(this, chatId);
|
|
480
|
-
}
|
|
481
|
-
}, _ChatListManager_handleUpdateChat = async function _ChatListManager_handleUpdateChat(update) {
|
|
482
|
-
const peer = { ...update, _: "peerChat" };
|
|
483
|
-
const chat = await __classPrivateFieldGet(this, _ChatListManager_c, "f").getEntity(peer);
|
|
484
|
-
const chatId = Api.peerToChatId(peer);
|
|
485
|
-
await __classPrivateFieldGet(this, _ChatListManager_c, "f").storage.setFullChat(chatId, null);
|
|
486
|
-
if (chat != null && "left" in chat && chat.left) {
|
|
487
|
-
await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_removeChat).call(this, chatId);
|
|
488
|
-
}
|
|
489
|
-
else if (Api.is("chatForbidden", chat)) {
|
|
490
|
-
await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_removeChat).call(this, chatId);
|
|
491
|
-
}
|
|
492
|
-
else if (Api.is("chat", chat)) {
|
|
493
|
-
await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_updateOrAddChat).call(this, chatId);
|
|
494
|
-
}
|
|
495
|
-
}, _ChatListManager_handleUpdateUser = async function _ChatListManager_handleUpdateUser(update) {
|
|
496
|
-
const peer = { ...update, _: "peerUser" };
|
|
497
|
-
const chat = await __classPrivateFieldGet(this, _ChatListManager_c, "f").getEntity(peer);
|
|
498
|
-
const chatId = Api.peerToChatId(peer);
|
|
499
|
-
await __classPrivateFieldGet(this, _ChatListManager_c, "f").storage.setFullChat(chatId, null);
|
|
500
|
-
if (chat != null) {
|
|
501
|
-
await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_updateOrAddChat).call(this, chatId);
|
|
502
|
-
}
|
|
503
|
-
}, _ChatListManager_getFullChat = async function _ChatListManager_getFullChat(chatId) {
|
|
504
|
-
const inputPeer = await __classPrivateFieldGet(this, _ChatListManager_c, "f").getInputPeer(chatId);
|
|
505
|
-
const chatId_ = await __classPrivateFieldGet(this, _ChatListManager_c, "f").getInputPeerChatId(inputPeer);
|
|
506
|
-
let fullChat = await __classPrivateFieldGet(this, _ChatListManager_c, "f").storage.getFullChat(chatId_);
|
|
507
|
-
if (fullChat != null) {
|
|
508
|
-
return fullChat;
|
|
509
|
-
}
|
|
510
|
-
if (canBeInputUser(inputPeer)) {
|
|
511
|
-
fullChat = (await __classPrivateFieldGet(this, _ChatListManager_c, "f").invoke({ _: "users.getFullUser", id: toInputUser(inputPeer) })).full_user;
|
|
512
|
-
}
|
|
513
|
-
else if (Api.is("inputPeerChat", inputPeer)) {
|
|
514
|
-
fullChat = (await __classPrivateFieldGet(this, _ChatListManager_c, "f").invoke({ ...inputPeer, _: "messages.getFullChat" })).full_chat;
|
|
515
|
-
}
|
|
516
|
-
else if (canBeInputChannel(inputPeer)) {
|
|
517
|
-
fullChat = (await __classPrivateFieldGet(this, _ChatListManager_c, "f").invoke({ _: "channels.getFullChannel", channel: toInputChannel(inputPeer) })).full_chat;
|
|
518
|
-
}
|
|
519
|
-
await __classPrivateFieldGet(this, _ChatListManager_c, "f").storage.setFullChat(chatId_, fullChat);
|
|
520
|
-
if (fullChat != null && "call" in fullChat && Api.is("inputGroupCall", fullChat.call)) {
|
|
521
|
-
await __classPrivateFieldGet(this, _ChatListManager_c, "f").storage.setGroupCallAccessHash(fullChat.call.id, fullChat.call.access_hash);
|
|
522
|
-
}
|
|
523
|
-
return fullChat;
|
|
524
|
-
}, _ChatListManager_checkChatTitle = function _ChatListManager_checkChatTitle(title) {
|
|
525
|
-
title = title.trim();
|
|
526
|
-
if (!title) {
|
|
527
|
-
throw new InputError("Title cannot be empty.");
|
|
528
|
-
}
|
|
529
|
-
return title;
|
|
530
|
-
}, _ChatListManager_createChannel = async function _ChatListManager_createChannel(type, title, params) {
|
|
531
|
-
title = __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_checkChatTitle).call(this, title);
|
|
532
|
-
const updates = await __classPrivateFieldGet(this, _ChatListManager_c, "f").invoke({
|
|
533
|
-
_: "channels.createChannel",
|
|
534
|
-
broadcast: type == "channel" ? true : undefined,
|
|
535
|
-
megagroup: type == "supergroup" ? true : undefined,
|
|
536
|
-
forum: params && ("forum" in params) && params.forum ? true : undefined,
|
|
537
|
-
title,
|
|
538
|
-
about: params?.description || "",
|
|
539
|
-
ttl_period: params?.messageTtl || undefined,
|
|
540
|
-
});
|
|
541
|
-
if (!("chats" in updates) || updates.chats.length < 1) {
|
|
542
|
-
unreachable();
|
|
543
|
-
}
|
|
544
|
-
const chat = updates.chats[0];
|
|
545
|
-
if (chat._ != "channel") {
|
|
546
|
-
unreachable();
|
|
547
|
-
}
|
|
548
|
-
return constructChatP(chat);
|
|
549
|
-
}, _ChatListManager_moveChatsToFolder = async function _ChatListManager_moveChatsToFolder(chatIds, folderId) {
|
|
550
|
-
const peers = await Promise.all(chatIds.map((v) => __classPrivateFieldGet(this, _ChatListManager_c, "f").getInputPeer(v)));
|
|
551
|
-
const inputFolderPeers = peers.map((v) => ({ _: "inputFolderPeer", peer: v, folder_id: folderId }));
|
|
552
|
-
await __classPrivateFieldGet(this, _ChatListManager_c, "f").invoke({ _: "folders.editPeerFolders", folder_peers: inputFolderPeers });
|
|
553
|
-
}, _ChatListManager_toggleBusinessBotsPaused = async function _ChatListManager_toggleBusinessBotsPaused(chatId, paused) {
|
|
554
|
-
const peer = await __classPrivateFieldGet(this, _ChatListManager_c, "f").getInputPeer(chatId);
|
|
555
|
-
if (!canBeInputUser(peer)) {
|
|
556
|
-
throw new InputError("A private chat was expected.");
|
|
557
|
-
}
|
|
558
|
-
await __classPrivateFieldGet(this, _ChatListManager_c, "f").invoke({ _: "account.toggleConnectedBotPaused", peer, paused });
|
|
559
|
-
};
|