This commit is contained in:
Timothy Jaeryang Baek committed 2026-08-02 16:48:23 -04:00
1 parent e2d7018cab
commit c95233d048
2 files changed
+18 -10

No files matched your search

+12 -2
View File
@@ -140,8 +140,18 @@ class SignalAdapter(BaseAdapter):
return timestamp
async def edit(self, chat_id: str, message_id: str, text: str) -> None:
"""Signal has no edit API; send the updated text as a new message."""
await self.send(chat_id, text)
if not self._http:
return
resp = await self._http.post(
f"{self._base_url}/v2/send",
json={
"message": text[:MAX_MESSAGE_LEN],
"number": self._phone,
"recipients": [chat_id],
"edit_timestamp": int(message_id),
},
)
resp.raise_for_status()
async def send_typing(self, chat_id: str) -> None:
"""Send typing indicator via signal-cli."""
+6 -8
View File
@@ -13,11 +13,10 @@ from __future__ import annotations
import asyncio
import logging
import time
import uuid
from abc import ABC, abstractmethod
from dataclasses import dataclass, field
from typing import Any, Awaitable, Callable, Optional
from typing import Awaitable, Callable, Optional
logger = logging.getLogger(__name__)
_current_bot_manager: "BotManager | None" = None
@@ -612,9 +611,6 @@ class BotManager:
file_entries match the web UI format so _load_message_history handles
them automatically (base64 for images, file:// refs for documents).
"""
from cptr.models import Config
from cptr.utils.config import _get_jwt_secret
from cptr.utils.crypto import decrypt_key
from cptr.utils.storage import get_storage
file_entries: list[dict] = []
@@ -915,13 +911,14 @@ class BotManager:
except Exception:
logger.exception("[bridge] Failed to send final chunk")
else:
# Discord: edit the placeholder, then send overflow
# Edit the placeholder, then send overflow.
if len(final_display) <= max_len and platform_msg_id:
try:
await adapter.edit(platform_chat_id, platform_msg_id, final_display)
return
except Exception:
pass
logger.debug("[bridge] Final edit failed", exc_info=True)
return
chunks = chunk_message(final_display, max_len)
if platform_msg_id and chunks:
@@ -929,7 +926,8 @@ class BotManager:
await adapter.edit(platform_chat_id, platform_msg_id, chunks[0])
chunks = chunks[1:]
except Exception:
pass
logger.debug("[bridge] Final chunk edit failed", exc_info=True)
return
for chunk in chunks:
try:
await adapter.send(platform_chat_id, chunk)