in ees_microsoft_teams/sync_enterprise_search.py [0:0]
def workplace_add_permission(self, permission_dict):
"""This method used to index the user permissions into Workplace Search
for the user in parameter user_name
:param user_name: A string value denoting the username of the user
:param permission: Permission that needs to be provided to the user
"""
try:
for user, roles in permission_dict.items():
user_permissions = split_documents_into_equal_chunks(
roles, PERMISSION_LIMIT
)
ws_permissions = self.workplace_search_custom_client.list_permissions()
for permissions in user_permissions:
if ws_permissions:
permission_lists = ws_permissions["results"]
for list_permission in permission_lists:
user_name = (
list_permission["user"]
if "user" in list_permission
else list_permission["external_user_properties"][0][
"attribute_value"
]
)
if user == user_name:
if list_permission["permissions"]:
permissions.extend(list_permission["permissions"])
self.workplace_search_custom_client.add_permissions(
user,
list(set(permissions)),
)
self.logger.info(
f"Successfully indexed the permissions for {user} user into the "
"Workplace Search"
)
except Exception as exception:
self.logger.exception(
f"Error while indexing the permissions to the workplace."
f"Error: {exception}"
)
raise exception