in ees_microsoft_teams/deletion_command.py [0:0]
def create_jobs_for_user_chats(self, thread_count, start_time, end_time, queue):
"""Creates jobs for deleting the user chats and its children objects
:param thread_count: Thread count to make partitions
:param start_time: Start time for fetching the data
:param end_time: End time for fetching the data
:param queue: Shared queue for storing the data
"""
if "user_chats" not in self.config.get_value('object_type_to_index'):
return
self.logger.debug("Started deletion the user chats, meeting chats, and meeting recordings...")
user_chat_object = self.microsoft_user_chats_object(self.get_access_token())
storage_with_collection = self.local_storage.get_documents_from_doc_id_storage("user_chats")
sync_ms_teams_obj = SyncMicrosoftTeams("deletion_sync", self.config, self.logger, queue)
try:
user_drive = {}
_, chats = user_chat_object.get_user_chats(ids_list=[])
chats_partition_list = split_documents_into_equal_chunks(chats, thread_count)
user_attachment_token = MSALAccessToken(self.logger, self.config)
user_attachment_token = user_attachment_token.get_token(
is_acquire_for_client=True
)
chat_messages_documents = self.create_and_execute_jobs(
thread_count, sync_ms_teams_obj.fetch_user_chat_messages_for_deletion,
(user_chat_object, [], user_drive, start_time, end_time, user_attachment_token),
chats_partition_list
)
deleted_data = storage_with_collection.get("delete_keys") or []
global_keys_documents = storage_with_collection.get("global_keys") or []
delete_keys_documents = []
self.remove_deleted_documents_from_global_keys(
chat_messages_documents, deleted_data, delete_keys_documents, global_keys_documents, "", ""
)
queue.append_to_queue("deletion", list(delete_keys_documents))
storage_with_collection["global_keys"] = list(global_keys_documents)
storage_with_collection["delete_keys"] = []
self.local_storage.update_storage(storage_with_collection, "user_chats")
except Exception as exception:
self.logger.exception(
f"Error while deleting user chats, meeting chats and meeting recordings. Error: "
f"{exception}"
)
self.logger.info("Completed deleting the user chats, meeting chats and meeting recordings")