Align UR startup flow and Signal/XMPP client runtime wiring

This commit is contained in:
2026-02-14 22:23:56 +00:00
parent d22eb8c811
commit 7732ff9b17
4 changed files with 18 additions and 11 deletions

View File

@@ -1,4 +1,3 @@
from rest_framework import status
import requests
@@ -11,7 +10,8 @@ import asyncio
async def start_typing(uuid):
url = f"http://signal:8080/v1/typing_indicator/{settings.SIGNAL_NUMBER}"
base = getattr(settings, "SIGNAL_HTTP_URL", "http://signal:8080").rstrip("/")
url = f"{base}/v1/typing_indicator/{settings.SIGNAL_NUMBER}"
data = {"recipient": uuid}
async with aiohttp.ClientSession() as session:
@@ -19,7 +19,8 @@ async def start_typing(uuid):
return await response.text() # Optional: Return response content
async def stop_typing(uuid):
url = f"http://signal:8080/v1/typing_indicator/{settings.SIGNAL_NUMBER}"
base = getattr(settings, "SIGNAL_HTTP_URL", "http://signal:8080").rstrip("/")
url = f"{base}/v1/typing_indicator/{settings.SIGNAL_NUMBER}"
data = {"recipient": uuid}
async with aiohttp.ClientSession() as session:
@@ -68,7 +69,8 @@ async def send_message_raw(recipient_uuid, text=None, attachments=[]):
Returns:
int | bool: Timestamp if successful, False otherwise.
"""
url = "http://signal:8080/v2/send"
base = getattr(settings, "SIGNAL_HTTP_URL", "http://signal:8080").rstrip("/")
url = f"{base}/v2/send"
data = {
"recipients": [recipient_uuid],
@@ -117,7 +119,8 @@ async def fetch_signal_attachment(attachment_id):
}
or None if the request fails.
"""
url = f"http://signal:8080/v1/attachments/{attachment_id}"
base = getattr(settings, "SIGNAL_HTTP_URL", "http://signal:8080").rstrip("/")
url = f"{base}/v1/attachments/{attachment_id}"
try:
async with aiohttp.ClientSession() as session:

View File

@@ -307,9 +307,6 @@ class XMPPComponent(ComponentXMPP):
self.log.warning("XMPP disconnected, attempting to reconnect...")
self.connect()
def session_start(self, *args):
self.log.info(f"Session started: {args}")
async def request_upload_slot(self, recipient, filename, content_type, size):
"""
Requests an upload slot from XMPP for HTTP File Upload (XEP-0363).
@@ -647,5 +644,8 @@ class XMPPClient(ClientBase):
def start(self):
self.log.info("XMPP client starting...")
# ensure slixmpp uses the same asyncio loop as the router
self.client.loop = self.loop
self.client.connect()
#self.client.process()

View File

@@ -13,6 +13,6 @@ class Command(BaseCommand):
instance = UnifiedRouter(loop)
instance.start()
#instance.start()
instance.run()

View File

@@ -17,14 +17,18 @@ class UnifiedRouter(object):
self.xmpp = XMPPClient(self, loop, "xmpp")
self.signal = SignalClient(self, loop, "signal")
def start(self):
def _start(self):
print("UR _start")
self.xmpp.start()
self.signal.start()
def run(self):
try:
self.xmpp.client.process()
#self.xmpp.client.client.process()
# self.xmpp.start()
print("IN RUN BEFORE START")
self._start()
self.loop.run_forever()
except (KeyboardInterrupt, SystemExit):
self.log.info("Process terminating")