Remeber which user added an entry by a saving a uid
This commit is contained in:
parent
c312e66afd
commit
9b9fcd6b02
2 changed files with 7 additions and 1 deletions
|
@ -38,6 +38,8 @@ class Entry:
|
||||||
:param uuid: The UUID, that identifies this exact entry in the queue.
|
:param uuid: The UUID, that identifies this exact entry in the queue.
|
||||||
Will be automatically assigned on creation.
|
Will be automatically assigned on creation.
|
||||||
:type uuid: UUID
|
: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
|
:param started_at: The timestamp this entry began playing. ``None``, if it
|
||||||
is yet to be played.
|
is yet to be played.
|
||||||
:type started_at: Optional[float]
|
:type started_at: Optional[float]
|
||||||
|
@ -55,6 +57,7 @@ class Entry:
|
||||||
failed: bool = False
|
failed: bool = False
|
||||||
skip: bool = False
|
skip: bool = False
|
||||||
uuid: UUID = field(default_factory=uuid4)
|
uuid: UUID = field(default_factory=uuid4)
|
||||||
|
uid: Optional[str] = None
|
||||||
started_at: Optional[float] = None
|
started_at: Optional[float] = None
|
||||||
|
|
||||||
def update(self, **kwargs: Any) -> None:
|
def update(self, **kwargs: Any) -> None:
|
||||||
|
|
|
@ -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
|
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
|
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
|
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
|
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
|
(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']}"})
|
await sio.emit("mst", {"msg": f"Unable to append {data['ident']}"})
|
||||||
return
|
return
|
||||||
|
|
||||||
|
entry.uid = data["uid"] if "uid" in data else None
|
||||||
|
|
||||||
first_song = state.queue.try_peek()
|
first_song = state.queue.try_peek()
|
||||||
if first_song is None or first_song.started_at is None:
|
if first_song is None or first_song.started_at is None:
|
||||||
start_time = datetime.datetime.now().timestamp()
|
start_time = datetime.datetime.now().timestamp()
|
||||||
|
|
Loading…
Add table
Reference in a new issue