Skip to content

Commit

Permalink
implement support for soft deletion of reactions
Browse files Browse the repository at this point in the history
  • Loading branch information
JimmyPettersson85 committed Oct 23, 2023
1 parent 53ed956 commit 7574ee1
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
6 changes: 5 additions & 1 deletion stream/reactions/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ def update(self, reaction_id, data=None, target_feeds=None):
pass

@abstractmethod
def delete(self, reaction_id):
def delete(self, reaction_id, soft=False):
pass

@abstractmethod
def restore(self, reaction_id):
pass

@abstractmethod
Expand Down
22 changes: 20 additions & 2 deletions stream/reactions/reaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,18 @@ def update(self, reaction_id, data=None, target_feeds=None):
data=payload,
)

def delete(self, reaction_id):
def delete(self, reaction_id, soft=False):
url = f"{self.API_ENDPOINT}{reaction_id}"
return self.client.delete(
url,
service_name=self.SERVICE_NAME,
signature=self.token,
params={"soft": soft},
)

def restore(self, reaction_id):
url = f"{self.API_ENDPOINT}{reaction_id}/restore"
return self.client.put(
url, service_name=self.SERVICE_NAME, signature=self.token
)

Expand Down Expand Up @@ -123,9 +132,18 @@ async def update(self, reaction_id, data=None, target_feeds=None):
data=payload,
)

async def delete(self, reaction_id):
async def delete(self, reaction_id, soft=False):
url = f"{self.API_ENDPOINT}{reaction_id}"
return await self.client.delete(
url,
service_name=self.SERVICE_NAME,
signature=self.token,
params={"soft": soft},
)

async def restore(self, reaction_id):
url = f"{self.API_ENDPOINT}{reaction_id}/restore"
return await self.client.put(
url, service_name=self.SERVICE_NAME, signature=self.token
)

Expand Down

0 comments on commit 7574ee1

Please sign in to comment.