Skip to content

Commit

Permalink
Fixes legacy message endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
brodokk committed Oct 15, 2024
1 parent 1b35d7b commit 23f31c8
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 13 deletions.
33 changes: 23 additions & 10 deletions resonitepy/classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -822,15 +822,12 @@ class ResoniteMessageType(Enum):
}


class ResoniteMessageContentText(str):
""" Class representing the content of a Resonite text message.
This will return directly a string.
"""

def __new__(cls, *args, **kw):
return str.__new__(cls, *args, **kw)
@dataclass
class ResoniteMessageContentText:
content: str

def __str__(self) -> str:
return self.content

@dataclass
class ResoniteMessageContentObject:
Expand Down Expand Up @@ -890,11 +887,14 @@ class ResoniteMessageContentSessionInvite:
normalizedSessionId: str
hostMachineId: str
hostUsername: str
hostUserId: str
hostUserSessionId: str
compatibilityHash: Optional[str]
universeId: Optional[str]
appVersion: Optional[str]
headlessHost: Optional[bool]
sessionURLs: List[str]
thumbnailUrl: Optional[str]
parentSessionIds: Optional[List[str]]
nestedSessionIds: Optional[List[str]]
sessionUsers: List[ResoniteSessionUser]
Expand All @@ -909,12 +909,15 @@ class ResoniteMessageContentSessionInvite:
lastUpdate: datetime
accessLevel: str
broadcastKey: Optional[str]
dataModelAssemblies: list # TODO: make it an object
hideFromListing: bool
systemCompatibilityHash: str


@dataclass
class ResoniteMessageContentSound:
id: str
OwnerId: Optional[str]
ownerId: Optional[str]
assetUri: str
globalVersion: Optional[int]
localVersion: Optional[int]
Expand All @@ -936,6 +939,11 @@ class ResoniteMessageContentSound:
randomOrder: int
submissions: Optional[str]
neosDBmanifest: Optional[list]
assetManifest: list # TODO: make it an object
isForPatrons: bool
version: dict # TODO: make it an object
isDeleted: bool
isReadOnly: Optional[bool]



Expand All @@ -954,7 +962,12 @@ class ResoniteMessage:
readTime: datetime
otherId: str
lastUpdateTime: datetime
content: ResoniteMessageContentText | ResoniteMessageContentSessionInvite | ResoniteMessageContentObject | ResoniteMessageContentSound
content: Optional[
ResoniteMessageContentText
| ResoniteMessageContentSessionInvite
| ResoniteMessageContentObject
| ResoniteMessageContentSound
]

@dataclass
class ResoniteCloudVar:
Expand Down
1 change: 1 addition & 0 deletions resonitepy/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,7 @@ def getMessageLegacy(
ResoniteMessageContentType = ResoniteMessageContentSound
elif message['messageType'] == 'Text':
ResoniteMessageContentType = ResoniteMessageContentText
message['content'] = {'content': message['content']}
else:
raise ValueError(f'Non supported type {message["messageType"]}')
message['content'] = to_class(
Expand Down
12 changes: 9 additions & 3 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@
Usage:
OWNERID=<Resonite U- user id> PASSWORD=<your password> python test.py
TODO:
- Add support for field in model but not send anymore, and raise an error too
"""

import os

from resonitepy.classes import ResoniteDirectory, ResoniteLink
from resonitepy.classes import ResoniteDirectory, ResoniteLink, ResoniteMessage, ResoniteMessageContentText
from resonitepy.client import Client
from resonitepy import classes

Expand All @@ -33,7 +36,6 @@
tested_directory = False
tested_link = False
for record in inventory:
print(type(record))
# TODO: test about ResoniteObject
if not tested_directory and isinstance(record, ResoniteDirectory):
directory = client.getDirectory(record)
Expand All @@ -44,4 +46,8 @@
tested_link = True
if tested_directory and tested_link:
break
platform = client.platform()
legacy_messages = client.getMessageLegacy()


# TODO: VERY IMPORTANT I NEED TO CONTINUE THIS AND PATCH MORE STUFF IF NEEDED BEFORE DOING A RELEASE!
platform = client.platform()

0 comments on commit 23f31c8

Please sign in to comment.