Skip to content

Commit

Permalink
feat: add support for undeleting messages
Browse files Browse the repository at this point in the history
  • Loading branch information
akupila committed Apr 9, 2024
1 parent 62a5ea0 commit 07e179b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions stream_chat/async_chat/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,9 @@ async def update_message_partial(
async def delete_message(self, message_id: str, **options: Any) -> StreamResponse:
return await self.delete(f"messages/{message_id}", options)

async def undelete_message(self, message_id: str, user_id: str) -> StreamResponse:
return await self.post(f"messages/{message_id}/undelete", data={"user": user_id})

async def get_message(self, message_id: str, **options: Any) -> StreamResponse:
return await self.get(f"messages/{message_id}", options)

Expand Down
9 changes: 9 additions & 0 deletions stream_chat/base/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,15 @@ def delete_message(
"""
pass

@abc.abstractmethod
def undelete_message(
self, message_id: str, user_id: str
) -> Union[StreamResponse, Awaitable[StreamResponse]]:
"""
Undeletes a message.
"""
pass

@abc.abstractmethod
def get_message(
self, message_id: str, **options: Any
Expand Down
5 changes: 5 additions & 0 deletions stream_chat/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,11 @@ def update_message_partial(
def delete_message(self, message_id: str, **options: Any) -> StreamResponse:
return self.delete(f"messages/{message_id}", options)

def undelete_message(self, message_id: str, user_id: str) -> StreamResponse:
return self.post(
f"messages/{message_id}/undelete", data={"undeleted_by": user_id}
)

def get_message(self, message_id: str, **options: Any) -> StreamResponse:
return self.get(f"messages/{message_id}", options)

Expand Down

0 comments on commit 07e179b

Please sign in to comment.