From cd1e830947d1349cff6d4ea55f5128ce531090b8 Mon Sep 17 00:00:00 2001 From: Vlad Stan Date: Fri, 23 Jun 2023 10:52:49 +0300 Subject: [PATCH] chore: code clean-up --- nostr/client/client.py | 2 +- services.py | 6 +++--- views_api.py | 3 +-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/nostr/client/client.py b/nostr/client/client.py index 239b8d5..e033262 100644 --- a/nostr/client/client.py +++ b/nostr/client/client.py @@ -1,5 +1,5 @@ import time -from typing import * +from typing import List from ..relay_manager import RelayManager diff --git a/services.py b/services.py index 5546d90..4cca4b3 100644 --- a/services.py +++ b/services.py @@ -72,7 +72,7 @@ class NostrRouter: t.cancel() except: pass - + for s in self.subscriptions: try: nostr.client.relay_manager.close_subscription(s) @@ -158,7 +158,7 @@ class NostrRouter: return if json_data[0] == "CLOSE": - self.handle_client_close(json_data[1]) + self._handle_client_close(json_data[1]) return if json_data[0] == "EVENT": @@ -180,7 +180,7 @@ class NostrRouter: self.subscriptions.append(subscription_id_rewritten) nostr.client.relay_manager.publish_message(request_rewritten) - def handle_client_close(self, subscription_id): + def _handle_client_close(self, subscription_id): subscription_id_rewritten = next((k for k, v in self.original_subscription_ids.items() if v == subscription_id), None) if subscription_id_rewritten: nostr.client.relay_manager.close_subscription(subscription_id_rewritten) diff --git a/views_api.py b/views_api.py index 131da44..374e25e 100644 --- a/views_api.py +++ b/views_api.py @@ -1,6 +1,6 @@ import asyncio from http import HTTPStatus -from typing import List, Optional +from typing import Optional from fastapi import Depends, WebSocket from loguru import logger @@ -14,7 +14,6 @@ from .crud import add_relay, delete_relay, get_relays from .helpers import normalize_public_key from .models import Relay, RelayList, TestMessage, TestMessageResponse from .nostr.key import EncryptedDirectMessage, PrivateKey -from .nostr.relay import Relay as NostrRelay from .services import NostrRouter, nostr # we keep this in