Skip to content

Commit

Permalink
Merge 10dbad1 into 73aec2d
Browse files Browse the repository at this point in the history
  • Loading branch information
fwump38 committed Oct 8, 2019
2 parents 73aec2d + 10dbad1 commit 7df1a9c
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 0 deletions.
1 change: 1 addition & 0 deletions AUTHORS.rst
Expand Up @@ -46,4 +46,5 @@ Source Contributors
- LilSpazJoekp `@LilSpazJoekp <https://github.com/LilSpazJoekp>`_
- Timendum `@timendum <https://github.com/timendum>`_
- vaclav-2012 `@vaclav-2012 <https://github.com/vaclav-2012>`_
- David Mirch `@fwump38 <https://github.com/fwump38>`_
- Add "Name <email (optional)> and github profile link" above this line.
9 changes: 9 additions & 0 deletions CHANGES.rst
@@ -1,6 +1,15 @@
Change Log
==========

Unreleased
----------

**Added**

* Comments/Submissions can now list/add Reddit redesign removal templates ``comment.mod.removal_reasons()`` and
``submission.mod.add_removal_reason()``. See: (:meth:`.ThingModerationMixin.removal_reasons` and
:meth:`.ThingModerationMixin.add_removal_reason`).

6.4.0 (2019/09/21)
------------------

Expand Down
2 changes: 2 additions & 0 deletions praw/endpoints.py
Expand Up @@ -133,6 +133,8 @@
"read_message": "api/read_message/",
"removal_comment_message": "api/v1/modactions/removal_comment_message",
"removal_link_message": "api/v1/modactions/removal_link_message",
"removal_reasons": "api/v1/modactions/removal_reasons",
"removal_reasons_list": "api/v1/{subreddit}/removal_reasons",
"remove": "api/remove/",
"report": "api/report/",
"rules": "r/{subreddit}/about/rules",
Expand Down
46 changes: 46 additions & 0 deletions praw/models/reddit/mixins/__init__.py
Expand Up @@ -139,6 +139,52 @@ def remove(self, spam=False):
data = {"id": self.thing.fullname, "spam": bool(spam)}
self.thing._reddit.post(API_PATH["remove"], data=data)

def removal_reasons(self):
"""Return list of available removal reasons.
reason ids are required in order to use :meth:`.add_removal_reason`.
For example:
.. code:: python
removal_reasons = submission.mod.removal_reasons()
"""
url = API_PATH["removal_reasons_list"].format(
subreddit=self.submission.subreddit
)
return self.submission._reddit.get(
url, data={"link": self.submission.fullname}
)["data"]

def add_removal_reason(self, reason_id, mod_note=""):
"""Add a removal reason for a Comment or Submission.
:param reason_id: The removal reason template ID.
:param mod_note: A message for the other mods on Reddit redesign
Example usage:
.. code:: python
# Select arbitrary reason (assuming there is any)
reasons = comment.mod.removal_reasons()
reason_id = next(x for x in reasons)
comment = reddit.comment('dkk4qjd')
comment.mod.add_removal_reason(reason_id=reason_id)
# remove a submission and add a mod note
submission = reddit.submission(id='5or86n')
submission.mod.remove(reason_id=""110ni21zo23ql", mod_note="foo")
"""
# Only the first element of the item_id list is used.
data = {
"item_ids": [self.thing.fullname],
"mod_note": mod_note,
"reason_id": reason_id,
}
self.thing._reddit.post(API_PATH["removal_reasons"], data=data)

def send_removal_message(
self,
message,
Expand Down

0 comments on commit 7df1a9c

Please sign in to comment.