Skip to content

Commit

Permalink
feat: add support for undeleting messages (#162)
Browse files Browse the repository at this point in the history
  • Loading branch information
akupila authored May 23, 2024
1 parent 4087024 commit c1da19d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions stream_chat/async_chat/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,11 @@ 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={"undeleted_by": 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 c1da19d

Please sign in to comment.