fix(feishu): restore assistant creation and pairing recovery
Refs NAN-239
This commit is contained in:
1 parent
cfb0f51e78
commit
2aa98677c6
36 files changed
+369
-47
No files matched your search
@@ -11,6 +11,7 @@ from nanobot.pairing.store import (
|
||||
handle_pairing_command,
|
||||
is_approved,
|
||||
list_pending,
|
||||
record_delivery,
|
||||
revoke,
|
||||
revoke_channel,
|
||||
)
|
||||
@@ -30,6 +31,7 @@ __all__ = [
|
||||
"handle_pairing_command",
|
||||
"is_approved",
|
||||
"list_pending",
|
||||
"record_delivery",
|
||||
"revoke",
|
||||
"revoke_channel",
|
||||
"PAIRING_CODE_META_KEY",
|
||||
|
||||
@@ -13,7 +13,7 @@ import string
|
||||
import threading
|
||||
import time
|
||||
from pathlib import Path
|
||||
from typing import Any, cast
|
||||
from typing import Any, Literal, cast
|
||||
|
||||
from loguru import logger
|
||||
|
||||
@@ -141,6 +141,26 @@ def generate_code(
|
||||
return code
|
||||
|
||||
|
||||
def record_delivery(code: str, status: Literal["sending", "sent", "failed"]) -> None:
|
||||
"""Record a reply outcome without changing approval or reviving a stale request.
|
||||
|
||||
Once a code has been sent, a failed concurrent retry must not hide it.
|
||||
Delivery bookkeeping is best-effort: a store error must not mask the actual
|
||||
transport result or reset any approvals.
|
||||
"""
|
||||
try:
|
||||
with _LOCK:
|
||||
data = _load()
|
||||
_gc_pending(data)
|
||||
info = data["pending"].get(code)
|
||||
if info is None or info.get("delivery_status") == "sent":
|
||||
return
|
||||
info["delivery_status"] = status
|
||||
_save(data)
|
||||
except OSError:
|
||||
logger.warning("Could not persist pairing reply delivery status")
|
||||
|
||||
|
||||
def approve_code(code: str) -> tuple[str, str] | None:
|
||||
"""Approve a pending pairing code.
|
||||
|
||||
|
||||
Reference in new issue
Block a user