This repository was archived by the owner on Dec 12, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +27
-7
lines changed
Expand file tree Collapse file tree 2 files changed +27
-7
lines changed Original file line number Diff line number Diff line change @@ -89,13 +89,11 @@ class Picture:
8989@dataclass_json (letter_case = LetterCase .CAMEL , undefined = Undefined .EXCLUDE )
9090@dataclass
9191class MiniProfile :
92- first_name : str
93- last_name : str
94- occupation : str
9592 entity_urn : URN
9693 public_identifier : str
97- tracking_id : str
98-
94+ first_name : Optional [str ] = None
95+ last_name : Optional [str ] = None
96+ occupation : Optional [str ] = None
9997 memorialized : bool = False
10098 picture : Optional [Picture ] = None
10199
@@ -197,10 +195,11 @@ class ThirdPartyMedia:
197195@dataclass_json (letter_case = LetterCase .CAMEL )
198196@dataclass
199197class MessageCustomContent :
200- third_party_media : ThirdPartyMedia = field (
198+ third_party_media : Optional [ ThirdPartyMedia ] = field (
201199 metadata = config (
202200 field_name = "com.linkedin.voyager.messaging.shared.ThirdPartyMedia"
203- )
201+ ),
202+ default = None ,
204203 )
205204
206205
Original file line number Diff line number Diff line change 66from datetime import datetime
77from typing import (
88 Any ,
9+ AsyncGenerator ,
910 Awaitable ,
1011 Callable ,
1112 DefaultDict ,
1920from bs4 import BeautifulSoup
2021
2122from .api_objects import (
23+ Conversation ,
2224 ConversationResponse ,
2325 ConversationsResponse ,
2426 MessageAttachmentCreate ,
@@ -219,6 +221,25 @@ async def get_conversations(
219221 conversations_resp = await self ._get ("/messaging/conversations" , params = params )
220222 return ConversationsResponse .from_json (await conversations_resp .text ())
221223
224+ async def get_all_conversations (self ) -> AsyncGenerator [Conversation , None ]:
225+ """
226+ A generator of all of the user's conversations using paging.
227+ """
228+ last_activity_before = datetime .now ()
229+ while True :
230+ conversations_response = await self .get_conversations (
231+ last_activity_before = last_activity_before
232+ )
233+ for c in conversations_response .elements :
234+ yield c
235+
236+ # The page size is 20, by default, so if we get less than 20, we are at the
237+ # end of the list so we should stop.
238+ if len (conversations_response .elements ) < 20 :
239+ break
240+
241+ last_activity_before = conversations_response .elements [- 1 ].last_activity_at
242+
222243 async def get_conversation (
223244 self ,
224245 conversation_urn : URN ,
You can’t perform that action at this time.
0 commit comments