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:
34
src/packetserver/client/messages.py
Normal file
34
src/packetserver/client/messages.py
Normal 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
|
||||
@@ -14,6 +14,9 @@ class UserWrapper:
|
||||
raise ValueError("Data dict was not an object dictionary.")
|
||||
self.data = data
|
||||
|
||||
def __repr__(self):
|
||||
return f"<UserWrapper: {self.username}>"
|
||||
|
||||
@property
|
||||
def socials(self) -> list[str]:
|
||||
return self.data['socials']
|
||||
|
||||
@@ -346,10 +346,15 @@ def handle_messages_since(req: Request, conn: PacketServerConnection, db: ZODB.D
|
||||
response.payload = msg_return
|
||||
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):
|
||||
if re.match(since_regex,req.path):
|
||||
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)
|
||||
username = ax25.Address(conn.remote_callsign).call.upper().strip()
|
||||
msg_return = []
|
||||
|
||||
Reference in New Issue
Block a user