@@ -705,6 +705,10 @@ class VkChatManager(QMainWindow):
self . _bulk_action_context = " set_user_admin " if action_type == " admin " else " execute_user_action "
self . _bulk_action_success_message_title = success_message_title
self . _bulk_clear_inputs_on_success = clear_inputs_on_success
self . _log_event (
" bulk_action " ,
f " start action= { action_type } chats= { len ( selected_chats ) } users= { len ( user_infos ) } " ,
)
self . _set_busy ( True , f " Статус: выполняется { action_label } (0/ { total } )... " )
self . _start_operation_progress ( total , action_label , action_button = action_button )
@@ -739,6 +743,10 @@ class VkChatManager(QMainWindow):
def _on_bulk_action_finished ( self , payload ) :
results = payload . get ( " results " , [ ] ) if isinstance ( payload , dict ) else [ ]
processed = payload . get ( " processed " ) if isinstance ( payload , dict ) else None
total = payload . get ( " total " ) if isinstance ( payload , dict ) else None
if processed is not None and total is not None :
self . _log_event ( " bulk_action " , f " done processed= { processed } total= { total } " )
QMessageBox . information ( self , self . _bulk_action_success_message_title , " \n " . join ( results ) )
if self . _bulk_clear_inputs_on_success :
self . vk_url_input . clear ( )
@@ -949,6 +957,7 @@ class VkChatManager(QMainWindow):
self . _log_event ( " auth_process " , " Авторизация уже запущена, повторный запуск пропущен. " )
return
self . _log_event ( " auth_process " , " start " )
if keep_status_text and hasattr ( self , " _relogin_status_text " ) :
status_text = self . _relogin_status_text
self . _relogin_status_text = None
@@ -990,6 +999,7 @@ class VkChatManager(QMainWindow):
self . _auth_relogin_in_progress = False
return
self . _log_event ( " auth_process " , f " success expires_in= { expires_in } " )
self . token = token
# Сохраняем и получаем корректный expiration_time (0 или будущее время)
try :
@@ -1265,6 +1275,7 @@ class VkChatManager(QMainWindow):
QMessageBox . warning ( self , " Ошибка " , " Сначала авторизуйтесь. " )
return
self . _log_event ( " resolve_ids " , f " start count= { len ( links_list ) } " )
self . user_ids_to_process . clear ( )
resolved_ids = [ ]
failed_links = [ ]
@@ -1288,6 +1299,10 @@ class VkChatManager(QMainWindow):
self . user_ids_to_process = resolved_ids
status_message = f " Статус: Готово к работе с { len ( resolved_ids ) } пользователем(ем/ями). "
self . _log_event (
" resolve_ids " ,
f " done resolved= { len ( resolved_ids ) } failed= { len ( failed_links ) } " ,
)
if len ( links_list ) > 1 :
self . _set_vk_url_input_text ( f " Загружено { len ( resolved_ids ) } / { len ( links_list ) } из списка " )
@@ -1314,17 +1329,40 @@ class VkChatManager(QMainWindow):
try :
self . _set_busy ( True , " Статус: загрузка чатов... " )
self . _log_event ( " load_chats " , " start " )
conversations = load_chat_conversations ( self . _vk_call_with_retry , self . vk )
type_counts = { }
non_chat_samples = [ ]
missing_title_count = 0
for conv in conversations :
if conv [ " conversation " ] [ " peer " ] [ " type " ] != " chat " :
conv_info = conv . get ( " conversation " , { } )
peer = conv_info . get ( " peer " , { } )
peer_type = peer . get ( " type " , " unknown " )
type_counts [ peer_type ] = type_counts . get ( peer_type , 0 ) + 1
if peer_type != " chat " :
if len ( non_chat_samples ) < 30 :
non_chat_samples . append (
{
" type " : peer_type ,
" peer_id " : peer . get ( " id " ) ,
" local_id " : peer . get ( " local_id " ) ,
" title " : ( conv_info . get ( " chat_settings " ) or { } ) . get ( " title " , " " ) ,
}
)
continue
chat_id = conv [ " conversation " ] [ " peer " ] [ " local_id " ]
title = conv [ " conversation " ] [ " chat_settings " ] [ " title " ]
chat_id = peer . get ( " local_id " )
chat_settings = conv_info . get ( " chat_settings " ) or { }
title = chat_settings . get ( " title " , " " )
if not title :
missing_title_count + = 1
self . chats . append ( { " id " : chat_id , " title " : title } )
checkbox = QCheckBox ( f " { title } (id: { chat_id } ) " )
checkbox . setProperty ( " chat_id " , chat_id )
if " группа магазинов " in title . casefold ( ) :
self . _log_event ( " load_chats " , f " chat_match title= ' { title } ' id= { chat_id } " )
if " AG офис " in title :
layouts [ 0 ] . insertWidget ( layouts [ 0 ] . count ( ) - 1 , checkbox )
self . office_chat_checkboxes . append ( checkbox )
@@ -1346,6 +1384,17 @@ class VkChatManager(QMainWindow):
self . chat_tabs . setTabText ( 2 , f " AG Склад ( { len ( self . warehouse_chat_checkboxes ) } ) " )
self . chat_tabs . setTabText ( 3 , f " AG Кофейни ( { len ( self . coffee_chat_checkboxes ) } ) " )
self . chat_tabs . setTabText ( 4 , f " Прочие ( { len ( self . other_chat_checkboxes ) } ) " )
self . _log_event (
" load_chats " ,
(
f " done total= { len ( conversations ) } "
f " chats= { len ( self . chats ) } "
f " type_counts= { type_counts } "
f " missing_titles= { missing_title_count } "
) ,
)
if non_chat_samples :
self . _log_event ( " load_chats " , f " non_chat_samples= { non_chat_samples } " )
except VkApiError as e :
if self . _handle_vk_api_error ( " load_chats " , e , action_name = " загрузки чатов " ) :
return