Skip to content

Commit

Permalink
[outlook] Filter users to only include active ones (#2967)
Browse files Browse the repository at this point in the history
Co-authored-by: Artem Shelkovnikov <[email protected]>
  • Loading branch information
2 people authored and elastic committed Nov 18, 2024
1 parent 0d9ec17 commit 5aec6df
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 3 additions & 1 deletion connectors/sources/outlook.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
html_to_text,
iso_utc,
retryable,
url_encode,
)

RETRIES = 3
Expand Down Expand Up @@ -410,7 +411,8 @@ async def _fetch_token(self):
)
async def get_users(self):
access_token = await self._fetch_token()
url = f"https://graph.microsoft.com/v1.0/users?$top={TOP}"
filter_ = url_encode("accountEnabled eq true")
url = f"https://graph.microsoft.com/v1.0/users?$top={TOP}&$filter={filter_}"
while True:
try:
async with self._get_session.get(
Expand Down
5 changes: 4 additions & 1 deletion tests/sources/test_outlook.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,10 @@ def side_effect_function(url, headers):
Args:
url, ssl: Params required for get call
"""
if url == "https://graph.microsoft.com/v1.0/users?$top=999":
if (
url
== "https://graph.microsoft.com/v1.0/users?$top=999&$filter=accountEnabled%20eq%20true"
):
return get_json_mock(
mock_response={
"@odata.nextLink": "https://graph.microsoft.com/v1.0/users?$top=999&$skipToken=fake-skip-token",
Expand Down

0 comments on commit 5aec6df

Please sign in to comment.