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 +40
-0
lines changed
Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Original file line number Diff line number Diff line change 1+ from pathlib import Path
2+
3+ import asyncio
4+ from linkedin_messaging import ChallengeException , LinkedInMessaging
5+ from linkedin_messaging .api_objects import URN
6+
7+ cookie_path = Path (__file__ ).parent .joinpath ("cookies.pickle" )
8+ urn = URN ("2-YWM2YTJmYjUtNTdjMS00ZjlmLTgwMDUtOWYxMmMxNjY4M2FlXzAxMg==" )
9+
10+
11+ async def main ():
12+ linkedin = LinkedInMessaging ()
13+ if cookie_path .exists ():
14+ with open (cookie_path , "rb" ) as cf :
15+ linkedin = LinkedInMessaging .from_pickle (cf .read ())
16+
17+ if not await linkedin .logged_in ():
18+ try :
19+ await linkedin .login ("EMAIL" , "PASSWORD" )
20+ except ChallengeException :
21+ await linkedin .enter_2fa (input ("2fa code: " ))
22+
23+ with open (cookie_path , "wb+" ) as cf :
24+ cf .write (linkedin .to_pickle ())
25+
26+ try :
27+ print (await linkedin .mark_conversation_as_read (urn ))
28+ finally :
29+ await linkedin .close ()
30+
31+
32+ loop = asyncio .get_event_loop ()
33+ loop .run_until_complete (main ())
Original file line number Diff line number Diff line change @@ -320,6 +320,13 @@ async def get_conversation(
320320 ConversationResponse , await try_from_json (ConversationResponse , res )
321321 )
322322
323+ async def mark_conversation_as_read (self , conversation_urn : URN ) -> bool :
324+ res = await self ._post (
325+ f"/messaging/conversations/{ conversation_urn .id_parts [- 1 ]} " ,
326+ json = {"patch" : {"$set" : {"read" : True }}},
327+ )
328+ return res .status == 200
329+
323330 # endregion
324331
325332 # region Messages
You can’t perform that action at this time.
0 commit comments