|
60 | 60 |
|
61 | 61 |
|
62 | 62 | # Helper Functions |
63 | | -def _fix_next_url(next_url): |
| 63 | +def _fix_next_url(next_url, params): |
64 | 64 | """Remove max=null parameter from URL. |
65 | 65 |
|
66 | 66 | Patch for Webex Teams Defect: "next" URL returned in the Link headers of |
@@ -96,6 +96,10 @@ def _fix_next_url(next_url): |
96 | 96 | query_list.remove("max=null") |
97 | 97 | warnings.warn("`max=null` still present in next-URL returned " |
98 | 98 | "from Webex Teams", RuntimeWarning) |
| 99 | + if params: |
| 100 | + for k, v in params.items(): |
| 101 | + if not any(p.startswith('{}='.format(k)) for p in query_list): |
| 102 | + query_list.append('{}={}'.format(k, v)) |
99 | 103 | new_query = "&".join(query_list) |
100 | 104 | parsed_url = list(parsed_url) |
101 | 105 | parsed_url[4] = new_query |
@@ -151,7 +155,7 @@ def user_agent(be_geo_id=None, caller=None): |
151 | 155 | data["cpu"] = platform.machine() |
152 | 156 |
|
153 | 157 | data["organization"] = {} |
154 | | - |
| 158 | + |
155 | 159 | # Add self-identified organization information to the User-Agent Header. |
156 | 160 | if be_geo_id: |
157 | 161 | data["organization"]["be_geo_id"] = be_geo_id |
@@ -231,7 +235,6 @@ def __init__(self, access_token, base_url, |
231 | 235 | if disable_ssl_verify: |
232 | 236 | self._req_session.verify = False |
233 | 237 |
|
234 | | - |
235 | 238 | if proxies is not None: |
236 | 239 | self._req_session.proxies.update(proxies) |
237 | 240 |
|
@@ -424,11 +427,13 @@ def get_pages(self, url, params=None, **kwargs): |
424 | 427 | if response.links.get("next"): |
425 | 428 | next_url = response.links.get("next").get("url") |
426 | 429 |
|
427 | | - # Patch for Webex Teams "max=null" in next URL bug. |
| 430 | + # Patch for Webex Teams "max=null" in next URL bug + missing |
| 431 | + # params, like mentionedPeople, which can be mandatory for |
| 432 | + # bots |
428 | 433 | # Testing shows that patch is no longer needed; raising a |
429 | 434 | # warnning if it is still taking effect; |
430 | 435 | # considering for future removal |
431 | | - next_url = _fix_next_url(next_url) |
| 436 | + next_url = _fix_next_url(next_url, params) |
432 | 437 |
|
433 | 438 | # Subsequent requests |
434 | 439 | response = self.request("GET", next_url, erc, **kwargs) |
|
0 commit comments