Skip to content

Commit

Permalink
Merge pull request #12 from db0/fix-comments
Browse files Browse the repository at this point in the history
Moderator remove and fix error in comments list
  • Loading branch information
NicKoehler authored Jun 20, 2023
2 parents d440b7f + 7dbb65c commit a27bb5a
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions pythorhead/comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ def list( # noqa: A003
if saved_only is not None:
list_comment["saved_only"] = saved_only
if sort is not None:
list_comment["sort"] = sort
list_comment["sort"] = sort.value
if type_ is not None:
list_comment["type"] = type_
list_comment["type"] = type_.value

if data := self._requestor.request(Request.GET, "/comment/list", params=list_comment):
return data["comments"]
Expand Down Expand Up @@ -184,6 +184,33 @@ def delete(self, comment_id: int, deleted: bool) -> Optional[dict]:
},
)

def remove(self, comment_id: int, removed: bool, reason: Optional[str] = None) -> Optional[dict]:
"""
Moderator remove / restore a comment.
Args:
comment_id (int)
removed (bool)
reason (str, optional): Defaults to None.
Returns:
Optional[dict]: removed comment data if successful
"""

remove_comment = {
"comment_id": comment_id,
"removed": removed,
}

if reason is not None:
remove_comment["reason"] = reason

return self._requestor.request(
Request.POST,
"/comment/remove",
json=remove_comment,
)

def save(self, comment_id: int, save: bool) -> Optional[dict]:
"""
Add / Remove a comment from saved.
Expand Down

0 comments on commit a27bb5a

Please sign in to comment.