diff --git a/syng/entry.py b/syng/entry.py index a9408a1..accc5ac 100644 --- a/syng/entry.py +++ b/syng/entry.py @@ -38,6 +38,8 @@ class Entry: :param uuid: The UUID, that identifies this exact entry in the queue. Will be automatically assigned on creation. :type uuid: UUID + :param uid: ID of the user that added this song to the queue. + :type uid: Optional[str] :param started_at: The timestamp this entry began playing. ``None``, if it is yet to be played. :type started_at: Optional[float] @@ -55,6 +57,7 @@ class Entry: failed: bool = False skip: bool = False uuid: UUID = field(default_factory=uuid4) + uid: Optional[str] = None started_at: Optional[float] = None def update(self, **kwargs: Any) -> None: diff --git a/syng/server.py b/syng/server.py index 9aba59a..3165d47 100644 --- a/syng/server.py +++ b/syng/server.py @@ -178,7 +178,8 @@ async def handle_append(sid: str, data: dict[str, Any]) -> None: This should be called from a web client. Appends the entry, that is encoded within the data to the room the client is currently connected to. An entry constructed this way, will be given a UUID, to differentiate it from other - entries for the same song. + entries for the same song. Additionally an id of the web client is saved + for that entry. If the room is configured to no longer accept songs past a certain time (via the :py:attr:`Config.last_song` attribute), it is checked, if the @@ -211,6 +212,8 @@ async def handle_append(sid: str, data: dict[str, Any]) -> None: await sio.emit("mst", {"msg": f"Unable to append {data['ident']}"}) return + entry.uid = data["uid"] if "uid" in data else None + first_song = state.queue.try_peek() if first_song is None or first_song.started_at is None: start_time = datetime.datetime.now().timestamp()