File tree Expand file tree Collapse file tree 2 files changed +27
-1
lines changed
Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change 99from .internal_utils import _next_cursor_is_present # type:ignore
1010
1111
12+ _LATEST_OFFSET_APIS = [
13+ 'discovery.conversations.history' ,
14+ 'discovery.conversations.edits' ,
15+ 'discovery.conversations.renames' ,
16+ 'discovery.conversations.reactions' ,
17+ ]
18+
19+
1220class DiscoveryResponse :
1321 """An iterable container of response data.
1422 Attributes:
@@ -120,6 +128,9 @@ def __next__(self):
120128 # offset for https://api.slack.com/enterprise/discovery/methods#users_list etc.
121129 params .update ({"offset" : self .body .get ("offset" )})
122130
131+ if any ([latest_offset_api in self .api_url for latest_offset_api in _LATEST_OFFSET_APIS ]):
132+ params .update ({"latest" : self .body .get ("offset" )})
133+
123134 response = self ._client .fetch_next_page ( # skipcq: PYL-W0212
124135 http_method = self .http_method ,
125136 api_url = self .api_url ,
Original file line number Diff line number Diff line change 11# Copyright 2021, Slack Technologies, LLC. All rights reserved.
22from typing import Any
33
4- import os , pytest , time
4+ import os , pytest , time , json
55from slack_sdk import WebClient
66from slack_discovery_sdk import DiscoveryClient
77from slack_discovery_sdk .internal_utils import (
@@ -91,6 +91,21 @@ def test_conversations_list_pagination(self):
9191 break
9292 assert len (conversations ) > limit_size
9393
94+ def test_conversations_history_pagination (self ):
95+ conversations = []
96+ limit_size = 1
97+ page_num = 0
98+ for page in self .client .discovery_conversations_history (channel = self .channel , team = self .team , limit = limit_size ):
99+ for message in page ['messages' ]:
100+ conversations .append (json .dumps (message ))
101+ page_num += 1
102+ if page_num > 5 :
103+ break
104+
105+ assert len (conversations ) > limit_size
106+ # ensure we are getting different messages for each page
107+ assert sorted (set (conversations )) == sorted (conversations )
108+
94109 def test_conversations_history_from_one_minute_ago (self ):
95110 test_text = "This first message will be used to test getting conversation history from the last minute"
96111 first_msg = None
You can’t perform that action at this time.
0 commit comments