Added stubs for message client module. Going to add a get message by uuid server method to allow clients to retrieve specific messages (if they want the attachments or text.. say).

This commit is contained in:
Michael Woods
2025-02-16 15:20:10 -05:00
parent a140740c92
commit 15dc18ce54
3 changed files with 42 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
import datetime
from packetserver.client import Client
from packetserver.common import Request, Response, PacketServerConnection
from typing import Union, Optional
from uuid import UUID, uuid4
import os.path
# TODO messages client
class MessageWrapper:
# TODO MessageWrapper
def __init__(self, data: dict):
for i in ['username', 'status', 'bio', 'socials', 'created_at', 'last_seen', 'email', 'location']:
if i not in data.keys():
raise ValueError("Data dict was not an object dictionary.")
self.data = data
def send_message(client: Client, bbs_callsign: str,):
# TODO send message
pass
def get_message_uuid():
# TODO get message by uuid
pass
def get_messages_since():
# TODO get messages since date
pass
def get_messages():
# TODO get messages default
pass

View File

@@ -14,6 +14,9 @@ class UserWrapper:
raise ValueError("Data dict was not an object dictionary.") raise ValueError("Data dict was not an object dictionary.")
self.data = data self.data = data
def __repr__(self):
return f"<UserWrapper: {self.username}>"
@property @property
def socials(self) -> list[str]: def socials(self) -> list[str]:
return self.data['socials'] return self.data['socials']

View File

@@ -346,10 +346,15 @@ def handle_messages_since(req: Request, conn: PacketServerConnection, db: ZODB.D
response.payload = msg_return response.payload = msg_return
send_response(conn, response, req) send_response(conn, response, req)
def handle_message_get_id(req: Request, conn: PacketServerConnection, db: ZODB.DB):
# TODO message get specific by uuid
pass
def handle_message_get(req: Request, conn: PacketServerConnection, db: ZODB.DB): def handle_message_get(req: Request, conn: PacketServerConnection, db: ZODB.DB):
if re.match(since_regex,req.path): if re.match(since_regex,req.path):
return handle_messages_since(req, conn, db) return handle_messages_since(req, conn, db)
elif 'id' in req.vars:
return handle_message_get_id(req, conn, db)
opts = parse_display_options(req) opts = parse_display_options(req)
username = ax25.Address(conn.remote_callsign).call.upper().strip() username = ax25.Address(conn.remote_callsign).call.upper().strip()
msg_return = [] msg_return = []