in ees_microsoft_outlook/microsoft_outlook_tasks.py [0:0]
def get_tasks(self, ids_list_tasks, accounts, start_time, end_time):
"""This method is used to fetch tasks from Microsoft Outlook
:param ids_list_tasks: List of ids of documents
:param accounts: List of user accounts
:param start_time: Start time for fetching the tasks
:param end_time: End time for fetching the tasks
Returns:
documents: List of documents
"""
documents = []
start_time = convert_datetime_to_ews_format(start_time)
end_time = convert_datetime_to_ews_format(end_time)
task_schema = get_schema_fields(
constant.TASKS_OBJECT.lower(), self.config.get_value("objects")
)
for account in accounts:
# Logic to set time zone according to user account
self.time_zone = account.default_timezone
try:
# Logic to fetch tasks
for task in (
account.tasks.all()
.filter(
last_modified_time__gt=start_time,
last_modified_time__lt=end_time,
)
.only(
"last_modified_time",
"due_date",
"complete_date",
"subject",
"status",
"owner",
"start_date",
"text_body",
"companies",
"categories",
"importance",
"has_attachments",
"attachments",
)
):
# Logic to insert task into global_keys object
insert_document_into_doc_id_storage(
ids_list_tasks,
task.id,
"",
constant.TASKS_OBJECT.lower(),
self.config.get_value("connector_platform_type"),
)
(task_obj, task_attachment,) = self.tasks_to_docs(
task,
ids_list_tasks,
account.primary_smtp_address,
start_time,
end_time,
)
task_map = {}
task_map["_allow_permissions"] = []
if self.config.get_value("enable_document_permission"):
task_map["_allow_permissions"] = [account.primary_smtp_address]
task_map["type"] = constant.TASKS_OBJECT
for ws_field, ms_field in task_schema.items():
task_map[ws_field] = task_obj[ms_field]
documents.append(task_map)
if task_attachment:
documents.extend(task_attachment)
except requests.exceptions.RequestException as request_error:
raise requests.exceptions.RequestException(
f"Error while fetching tasks data for {account.primary_smtp_address}. Error: {request_error}"
)
except Exception as exception:
self.logger.info(
f"Error while fetching tasks data for {account.primary_smtp_address}. Error: {exception}"
)
pass
return list(unique_everseen(documents))