Skip to content

Commit 83a6c60

Browse files
authored
Merge pull request GrafeasGroup#353 from GrafeasGroup/handle-blocked-volunteers
Update message when user is blocked
2 parents af92af5 + fe0a5c3 commit 83a6c60

File tree

5 files changed

+93
-36
lines changed

5 files changed

+93
-36
lines changed

.github/workflows/automated-tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
pip install poetry
2121
hash -r
2222
23-
poetry install -v --extras ci
23+
poetry install
2424
- run: poetry run mypy .
2525
- run: poetry run flake8 .
2626

@@ -40,5 +40,5 @@ jobs:
4040
pip install poetry
4141
hash -r
4242
43-
poetry install -v --extras ci
43+
poetry install
4444
- run: poetry run pytest --cov=tor

poetry.lock

Lines changed: 65 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ toml = "^0.10.2"
2727
honeycomb-beeline = "^3.4.1"
2828
shiv = "^1.0.1"
2929
click = "^8.1.3"
30+
pytest = "^7.1.2"
3031

3132
[tool.poetry.dev-dependencies]
3233
better-exceptions = "^0.3.3"
33-
pytest = "^7.1.2"
3434
pytest-cov = "^3.0.0"
3535
flake8 = "^5.0.3"
3636
mypy = ">=0.800"
@@ -45,9 +45,6 @@ poetry2setup = "^1.0.0"
4545
[tool.poetry.plugins."console_scripts"]
4646
"tor" = "tor.cli.main:main"
4747

48-
[tool.poetry.extras]
49-
ci = ['pytest', 'pytest-cov']
50-
5148
[[tool.mypy.overrides]]
5249
module = [
5350
"praw",

tor/core/user_interaction.py

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import logging
22
import random
33
import time
4-
from typing import Dict, Tuple
4+
from typing import Tuple
55

66
from tor.core.config import (
77
SLACK_COC_ACCEPTED_CHANNEL_ID,
@@ -48,9 +48,18 @@
4848
]
4949

5050

51+
def modchat_blocked_user_ping(username: str, blossom_submission: dict, cfg: Config) -> None:
52+
user_url = i18n["urls"]["reddit_url"].format(f"/u/{username}")
53+
send_to_modchat(
54+
f":no_entry_sign: Blocked user <{user_url}|u/{username}> is trying to transcribe."
55+
f" <{blossom_submission['tor_url']}|Thread link>",
56+
cfg,
57+
)
58+
59+
5160
@beeline.traced(name="process_coc")
5261
def process_coc(
53-
username: str, context: str, blossom_submission: Dict, cfg: Config
62+
username: str, context: str, blossom_submission: dict, cfg: Config
5463
) -> Tuple:
5564
"""
5665
Process the acceptation of the CoC by the specified user.
@@ -93,7 +102,7 @@ def process_coc(
93102

94103
@beeline.traced(name="process_claim")
95104
def process_claim(
96-
username: str, blossom_submission: Dict, cfg: Config, first_time=False
105+
username: str, blossom_submission: dict, cfg: Config, first_time=False
97106
) -> Tuple:
98107
"""
99108
Process a claim request.
@@ -138,8 +147,9 @@ def process_claim(
138147
message = coc_not_accepted.format(get_wiki_page("codeofconduct", cfg))
139148
cfg.blossom.create_user(username=username)
140149

141-
elif response.status == BlossomStatus.blacklisted:
142-
message = i18n["responses"]["general"]["blacklisted"]
150+
elif response.status == BlossomStatus.blocked:
151+
message = i18n["responses"]["general"]["blocked"]
152+
modchat_blocked_user_ping(username, blossom_submission, cfg)
143153

144154
elif response.status == BlossomStatus.already_claimed:
145155
claimed_by = response.data["username"]
@@ -167,7 +177,7 @@ def process_claim(
167177
@beeline.traced(name="process_done")
168178
def process_done(
169179
user: Redditor,
170-
blossom_submission: Dict,
180+
blossom_submission: dict,
171181
comment: Comment,
172182
cfg: Config,
173183
override=False,
@@ -289,15 +299,16 @@ def process_done(
289299
elif done_response.status == BlossomStatus.missing_prerequisite:
290300
message = done_messages["not_claimed_by_user"]
291301

292-
elif done_response.status == BlossomStatus.blacklisted:
293-
message = i18n["responses"]["general"]["blacklisted"]
302+
elif done_response.status == BlossomStatus.blocked:
303+
message = i18n["responses"]["general"]["blocked"]
304+
modchat_blocked_user_ping(user.name, blossom_submission, cfg)
294305

295306
return message, return_flair
296307

297308

298309
@beeline.traced(name="process_unclaim")
299310
def process_unclaim(
300-
username: str, blossom_submission: Dict, submission: Submission, cfg: Config
311+
username: str, blossom_submission: dict, submission: Submission, cfg: Config
301312
) -> Tuple:
302313
"""
303314
Process an unclaim request.
@@ -331,8 +342,9 @@ def process_unclaim(
331342
message = unclaim_messages["claimed_other_user"]
332343
elif response.status == BlossomStatus.already_completed:
333344
message = unclaim_messages["post_already_completed"]
334-
elif response.status == BlossomStatus.blacklisted:
335-
message = i18n["responses"]["general"]["blacklisted"]
345+
elif response.status == BlossomStatus.blocked:
346+
message = i18n["responses"]["general"]["blocked"]
347+
modchat_blocked_user_ping(username, blossom_submission, cfg)
336348
else:
337349
message = unclaim_messages["still_unclaimed"]
338350
return message, return_flair

tor/strings/en_US.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,8 @@ responses:
166166
general:
167167
getting_help: |
168168
✅ Help is on the way! I have notified the mods and someone should be here to assist you soon.
169-
blacklisted: |
170-
It appears that you are blacklisted. Please contact the moderators of r/TranscribersOfReddit if you do not know why this is the case.
169+
blocked: |
170+
Sorry, you can't transcribe at this time. Please [message the mods](https://www.reddit.com/message/compose?to=%2Fr%2FTranscribersOfReddit&subject=Blocked%20from%20Transcribing&message=) through modmail.
171171
oops: |
172172
⛔ Something appears to have gone wrong. Please message the moderators of r/TranscribersOfReddit to have them look at this. Thanks!
173173
coc_not_accepted: |

0 commit comments

Comments
 (0)