Skip to content

Commit 689c2d1

Browse files
committed
in progress
1 parent 2df1ef5 commit 689c2d1

File tree

5 files changed

+43
-9
lines changed

5 files changed

+43
-9
lines changed

sogs/model/clientmanager.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from typing import Optional, List, Union, Any
1616
import time
1717

18+
1819
"""
1920
Complications:
2021
- given captcha bot
@@ -78,11 +79,8 @@ class ClientManager:
7879

7980
def __init__(
8081
self,
81-
_rooms: List[Room],
82-
row=None,
8382
*,
8483
id: Optional[int] = None,
85-
session_id: Optional[int] = None,
8684
) -> None:
8785
self.id = id
8886
self.filter = False

sogs/mule.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ def setup_omq(self, omq: OMQ):
9292
worker.add_command("message_edited", self.message_edited)
9393

9494
# new client code
95+
# TOFIX: use add_request_command to handle a response value
9596
handler = self._omq.add_category("handler", access_level=oxenmq.AuthLevel.admin)
9697
handler.add_command("register_client", omq.register_client)
9798
handler.add_command("deregister_client", omq.deregister_client)
@@ -104,3 +105,17 @@ def setup_omq(self, omq: OMQ):
104105
# it will work. (And so be careful not to recurse!)
105106
app.logger.debug("Mule connecting to self")
106107
omq.mule_conn = omq.connect_inproc(on_success=None, on_failure=self.inproc_fail)
108+
109+
110+
111+
"""
112+
TOFIX: oxenmq calls should pass as oxenmq.Message not as JSON
113+
114+
def _on_subscribe(self, msg: oxenmq.Message):
115+
code, message = None, None # If still None at the end, we send a reply
116+
try:
117+
args = json.loads(msg.data()[0])
118+
119+
pubkey = extract_hex_or_b64(args, "pubkey", 33)
120+
121+
"""

sogs/routes/clients.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@
99

1010
# User-related routes
1111

12+
"""
13+
TOFIX:
14+
remove HTTP shit from requests
15+
16+
"""
17+
1218

1319
clients = Blueprint('clients', __name__)
1420

@@ -18,7 +24,7 @@ def register(cid):
1824
"""
1925
Registers a client with SOGS OMQ instance. In this context, "client" refers to any entity
2026
seeking to create an authenticated OMQ connection. This may be, but is not limited to,
21-
a user or a bot.
27+
a user or a bot
2228
2329
## URL Parameters
2430
@@ -80,9 +86,7 @@ def register_bot(cid, authlevel, priority):
8086
@clients.post("/client/registered/client/<cid>")
8187
def register_client(cid, authlevel):
8288
"""
83-
Registers a non-bot client with SOGS OMQ instance. In this context, "client" refers to any entity
84-
seeking to create an authenticated OMQ connection. This may be, but is not limited to,
85-
a user or a bot.
89+
Registers a non-bot client with SOGS OMQ instance
8690
8791
## URL Parameters
8892
@@ -127,7 +131,6 @@ def unregister(cid):
127131
return client
128132

129133

130-
131134
@clients.post("/client/deregistered/client/<cid>")
132135
@clients.delete("/client/registered/client/<cid>")
133136
def unregister_client(cid):

sogs/routes/messages.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,11 @@ def message_single(room: Room, msg_id):
310310
return utils.jsonify_with_base64(msgs[0])
311311

312312

313+
"""
314+
TOFIX:
315+
- add some decorator to this s.t. it routes it to the correct OMQ endpoint
316+
"""
317+
313318
@messages.post("/room/<Room:room>/message")
314319
@auth.user_required
315320
def post_message(room: Room):

sogs/routes/omq_auth.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def handle_omq_registration(sid, authlevel):
105105
"""
106106
Here goes ye olde OMQ registration logic. We need to decide what identification will
107107
be used to verify every connected client s.t. that information persists for all subsequent
108-
requests.
108+
requests
109109
110110
In this registration, we need to set:
111111
g.client_id
@@ -124,3 +124,16 @@ def verify_omq_auth():
124124
if hasattr(g, 'client_id') and hasattr(g, 'client_authlevel') and not g.client_reauth:
125125
app.logger.debug(f"Client {g.client_id} already authenticated for {g.client_authlevel} access")
126126
return
127+
128+
129+
130+
"""
131+
TOFIX:
132+
- add some type of dict in omq_global to map conn_ID (onenmq conn ID) to session_ID/other info
133+
- do not persist:
134+
- room specific access: check every time it makes a request because it can change
135+
- values that admin level can change
136+
137+
138+
139+
"""

0 commit comments

Comments
 (0)