simplify(pairing): address review findings — constants, TOCTOU, nesting
- Remove TOCTOU exists() check in _load(); rely on FileNotFoundError - Define PAIRING_CODE_META_KEY and PAIRING_COMMAND_META_KEY constants in nanobot.pairing, replacing magic strings across base.py, slack.py, and builtin.py - Flatten nested revoke logic in handle_pairing_command() - Trim redundant docstring/comment noise in is_allowed() and generate_code()
This commit is contained in:
@@ -548,14 +548,14 @@ async def cmd_history(ctx: CommandContext) -> OutboundMessage:
|
||||
|
||||
async def cmd_pairing(ctx: CommandContext) -> OutboundMessage:
|
||||
"""List, approve, deny or revoke pairing requests."""
|
||||
from nanobot.pairing import handle_pairing_command
|
||||
from nanobot.pairing import PAIRING_COMMAND_META_KEY, handle_pairing_command
|
||||
|
||||
reply = handle_pairing_command(ctx.msg.channel, ctx.args)
|
||||
return OutboundMessage(
|
||||
channel=ctx.msg.channel,
|
||||
chat_id=ctx.msg.chat_id,
|
||||
content=reply,
|
||||
metadata={"_pairing_command": True},
|
||||
metadata={PAIRING_COMMAND_META_KEY: True},
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user