Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions webexteamssdk/restsession.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@


# Helper Functions
def _fix_next_url(next_url):
def _fix_next_url(next_url, params):
"""Remove max=null parameter from URL.

Patch for Webex Teams Defect: "next" URL returned in the Link headers of
Expand Down Expand Up @@ -96,6 +96,10 @@ def _fix_next_url(next_url):
query_list.remove("max=null")
warnings.warn("`max=null` still present in next-URL returned "
"from Webex Teams", RuntimeWarning)
if params:
for k, v in params.items():
if not any(p.startswith('{}='.format(k)) for p in query_list):
query_list.append('{}={}'.format(k, v))
new_query = "&".join(query_list)
parsed_url = list(parsed_url)
parsed_url[4] = new_query
Expand Down Expand Up @@ -151,7 +155,7 @@ def user_agent(be_geo_id=None, caller=None):
data["cpu"] = platform.machine()

data["organization"] = {}

# Add self-identified organization information to the User-Agent Header.
if be_geo_id:
data["organization"]["be_geo_id"] = be_geo_id
Expand Down Expand Up @@ -231,7 +235,6 @@ def __init__(self, access_token, base_url,
if disable_ssl_verify:
self._req_session.verify = False


if proxies is not None:
self._req_session.proxies.update(proxies)

Expand Down Expand Up @@ -424,11 +427,13 @@ def get_pages(self, url, params=None, **kwargs):
if response.links.get("next"):
next_url = response.links.get("next").get("url")

# Patch for Webex Teams "max=null" in next URL bug.
# Patch for Webex Teams "max=null" in next URL bug + missing
# params, like mentionedPeople, which can be mandatory for
# bots
# Testing shows that patch is no longer needed; raising a
# warnning if it is still taking effect;
# considering for future removal
next_url = _fix_next_url(next_url)
next_url = _fix_next_url(next_url, params)

# Subsequent requests
response = self.request("GET", next_url, erc, **kwargs)
Expand Down