Skip to content

Commit

Permalink
Remove legacy modmail endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
bboe committed Feb 5, 2025
1 parent 552e600 commit 4284b50
Show file tree
Hide file tree
Showing 7 changed files with 2 additions and 454 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ Unreleased
- Remove ``Comment.gild``, ``Redditor.gild``, and ``Submission.gild`` methods.
- Remove ``Redditor.gilded`` and ``Subreddit.gilded`` methods.
- Remove ``Redditor.gildings`` method.
- Remove ``Subreddit.mod.inbox``, ``Subreddit.mod.unread``, and
``Subreddit.mod.stream.unread`` methods.
- Remove ``Subreddits.gold`` method.
- Remove :class:`.Reddit` keyword argument ``token_manager`` and all associated token
managers.
Expand Down
2 changes: 0 additions & 2 deletions praw/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,6 @@
"mod_notes": "api/mod/notes",
"mod_notes_bulk": "api/mod/notes/recent",
"moderated": "user/{user}/moderated_subreddits/",
"moderator_messages": "r/{subreddit}/message/moderator/",
"moderator_unread": "r/{subreddit}/message/moderator/unread/",
"modmail_archive": "api/mod/conversations/{id}/archive",
"modmail_bulk_read": "api/mod/conversations/bulk/read",
"modmail_conversation": "api/mod/conversations/{id}",
Expand Down
5 changes: 0 additions & 5 deletions praw/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,6 @@ def __init__(self, message: str):
"""Initialize a :class:`.WebSocketException` instance.
:param message: The exception message.
:param exception: The exception thrown by the websocket library.
.. note::
This parameter is deprecated. It will be removed in PRAW 8.0.
"""
super().__init__(message)
Expand Down
96 changes: 0 additions & 96 deletions praw/models/reddit/subreddit.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from pathlib import Path
from typing import TYPE_CHECKING, Any
from urllib.parse import urljoin
from warnings import warn

import websocket
from defusedxml import ElementTree
Expand Down Expand Up @@ -854,45 +853,6 @@ def edited(
**generator_kwargs,
)

def inbox(self, **generator_kwargs: Any) -> Iterator[praw.models.SubredditMessage]:
"""Return a :class:`.ListingGenerator` for moderator messages.
.. warning::
Legacy modmail is being deprecated in June 2021. Please see
https://www.reddit.com/r/modnews/comments/mar9ha/even_more_modmail_improvements/
for more info.
Additional keyword arguments are passed in the initialization of
:class:`.ListingGenerator`.
.. seealso::
:meth:`.unread` for unread moderator messages.
To print the last 5 moderator mail messages and their replies, try:
.. code-block:: python
for message in reddit.subreddit("mod").mod.inbox(limit=5):
print(f"From: {message.author}, Body: {message.body}")
for reply in message.replies:
print(f"From: {reply.author}, Body: {reply.body}")
"""
warn(
"Legacy modmail is being deprecated in June 2021. Please see"
" https://www.reddit.com/r/modnews/comments/mar9ha/even_more_modmail_improvements/"
" for more info.",
category=DeprecationWarning,
stacklevel=3,
)
return ListingGenerator(
self.subreddit._reddit,
API_PATH["moderator_messages"].format(subreddit=self.subreddit),
**generator_kwargs,
)

def log(
self,
*,
Expand Down Expand Up @@ -1029,43 +989,6 @@ def unmoderated(self, **generator_kwargs: Any) -> Iterator[praw.models.Submissio
**generator_kwargs,
)

def unread(self, **generator_kwargs: Any) -> Iterator[praw.models.SubredditMessage]:
"""Return a :class:`.ListingGenerator` for unread moderator messages.
.. warning::
Legacy modmail is being deprecated in June 2021. Please see
https://www.reddit.com/r/modnews/comments/mar9ha/even_more_modmail_improvements/
for more info.
Additional keyword arguments are passed in the initialization of
:class:`.ListingGenerator`.
.. seealso::
:meth:`.inbox` for all messages.
To print the mail in the unread modmail queue try:
.. code-block:: python
for message in reddit.subreddit("mod").mod.unread():
print(f"From: {message.author}, To: {message.dest}")
"""
warn(
"Legacy modmail is being deprecated in June 2021. Please see"
" https://www.reddit.com/r/modnews/comments/mar9ha/even_more_modmail_improvements/"
" for more info.",
category=DeprecationWarning,
stacklevel=3,
)
return ListingGenerator(
self.subreddit._reddit,
API_PATH["moderator_unread"].format(subreddit=self.subreddit),
**generator_kwargs,
)

def update(self, **settings: str | int | bool) -> dict[str, str | int | bool]:
"""Update the :class:`.Subreddit`'s settings.
Expand Down Expand Up @@ -1356,25 +1279,6 @@ def unmoderated(self, **stream_options: Any) -> Generator[praw.models.Submission
"""
return stream_generator(self.subreddit.mod.unmoderated, **stream_options)

def unread(self, **stream_options: Any) -> Generator[praw.models.SubredditMessage, None, None]:
"""Yield unread old modmail messages as they become available.
Keyword arguments are passed to :func:`.stream_generator`.
.. seealso::
:meth:`.SubredditModeration.inbox` for all messages.
To print new mail in the unread modmail queue try:
.. code-block:: python
for message in reddit.subreddit("mod").mod.stream.unread():
print(f"From: {message.author}, To: {message.dest}")
"""
return stream_generator(self.subreddit.mod.unread, **stream_options)


class SubredditQuarantine:
"""Provides subreddit quarantine related methods.
Expand Down
102 changes: 0 additions & 102 deletions tests/integration/cassettes/TestSubredditModeration.test_unread.json

This file was deleted.

This file was deleted.

25 changes: 0 additions & 25 deletions tests/integration/models/reddit/test_subreddit.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,15 +459,6 @@ def test_edited__only_submissions(self, reddit):
count += 1
assert count > 0

def test_inbox(self, reddit):
reddit.read_only = False
count = 0
subreddit = reddit.subreddit("all")
for item in subreddit.mod.inbox():
assert isinstance(item, SubredditMessage)
count += 1
assert count == 100

def test_log(self, reddit):
reddit.read_only = False
count = 0
Expand Down Expand Up @@ -601,15 +592,6 @@ def test_unmoderated(self, reddit):
count += 1
assert count > 0

def test_unread(self, reddit):
reddit.read_only = False
count = 0
subreddit = reddit.subreddit("all")
for item in subreddit.mod.unread():
assert isinstance(item, SubredditMessage)
count += 1
assert count > 0

def test_update(self, reddit):
reddit.read_only = False
subreddit = reddit.subreddit(pytest.placeholders.test_subreddit)
Expand Down Expand Up @@ -680,13 +662,6 @@ def test_unmoderated(self, reddit):
for i in range(10):
assert isinstance(next(generator), (Comment, Submission))

def test_unread(self, reddit):
reddit.read_only = False
subreddit = reddit.subreddit("mod")
generator = subreddit.mod.stream.unread()
for i in range(2):
assert isinstance(next(generator), SubredditMessage)


class TestSubredditModmail(IntegrationTest):
def test_bulk_read(self, reddit):
Expand Down

0 comments on commit 4284b50

Please sign in to comment.