Add -temp rooms and persistent room notices
This commit is contained in:
parent
4329d22334
commit
98b0d89981
@ -640,6 +640,7 @@ class SyncplayClient(object):
|
||||
"chat": utils.meetsMinVersion(self.serverVersion, constants.CHAT_MIN_VERSION),
|
||||
"readiness": utils.meetsMinVersion(self.serverVersion, constants.USER_READY_MIN_VERSION),
|
||||
"managedRooms": utils.meetsMinVersion(self.serverVersion, constants.CONTROLLED_ROOMS_MIN_VERSION),
|
||||
"persistentRooms": False,
|
||||
"maxChatMessageLength": constants.FALLBACK_MAX_CHAT_MESSAGE_LENGTH,
|
||||
"maxUsernameLength": constants.FALLBACK_MAX_USERNAME_LENGTH,
|
||||
"maxRoomNameLength": constants.FALLBACK_MAX_ROOM_NAME_LENGTH,
|
||||
@ -711,6 +712,7 @@ class SyncplayClient(object):
|
||||
features["featureList"] = True
|
||||
features["readiness"] = True
|
||||
features["managedRooms"] = True
|
||||
features["persistentRooms"] = True
|
||||
|
||||
return features
|
||||
|
||||
|
||||
@ -458,6 +458,7 @@ de = {
|
||||
|
||||
# Server messages to client
|
||||
"new-syncplay-available-motd-message": "Du nutzt Syncplay Version {}, aber es gibt eine neuere Version auf https://syncplay.pl", # ClientVersion
|
||||
"persistent-rooms-notice": "NOTICE: This server uses persistent rooms, which means that the playlist information is stored between playback sessions. If you want to create a room where information is not saved then put -temp at the end of the room name.", # TO DO: Translate - NOTE: Do not translate the word -temp
|
||||
|
||||
# Server notifications
|
||||
"welcome-server-notification": "Willkommen zum Syncplay-Server, v. {0}", # version
|
||||
|
||||
@ -458,6 +458,7 @@ en = {
|
||||
|
||||
# Server messages to client
|
||||
"new-syncplay-available-motd-message": "You are using Syncplay {} but a newer version is available from https://syncplay.pl", # ClientVersion
|
||||
"persistent-rooms-notice": "NOTICE: This server uses persistent rooms, which means that the playlist information is stored between playback sessions. If you want to create a room where information is not saved then put -temp at the end of the room name.", # NOTE: Do not translate the word -temp
|
||||
|
||||
# Server notifications
|
||||
"welcome-server-notification": "Welcome to Syncplay server, ver. {0}", # version
|
||||
|
||||
@ -457,6 +457,7 @@ es = {
|
||||
|
||||
# Server messages to client
|
||||
"new-syncplay-available-motd-message": "Estás usando Syncplay {} pero hay una versión más nueva disponible en https://syncplay.pl", # ClientVersion
|
||||
"persistent-rooms-notice": "NOTICE: This server uses persistent rooms, which means that the playlist information is stored between playback sessions. If you want to create a room where information is not saved then put -temp at the end of the room name.", # TO DO: Translate - NOTE: Do not translate the word -temp
|
||||
|
||||
# Server notifications
|
||||
"welcome-server-notification": "Bienvenido al servidor de Syncplay, ver. {0}", # version
|
||||
|
||||
@ -457,6 +457,7 @@ it = {
|
||||
|
||||
# Server messages to client
|
||||
"new-syncplay-available-motd-message": "Stai usando Syncplay {} ma una nuova versione è disponibile presso https://syncplay.pl", # ClientVersion
|
||||
"persistent-rooms-notice": "NOTICE: This server uses persistent rooms, which means that the playlist information is stored between playback sessions. If you want to create a room where information is not saved then put -temp at the end of the room name.", # TO DO: Translate - NOTE: Do not translate the word -temp to create a room where information is not saved then put -temp at the end of the room name.", # TO DO: Translate
|
||||
|
||||
# Server notifications
|
||||
"welcome-server-notification": "Benvenuto nel server Syncplay, ver. {0}", # version
|
||||
|
||||
@ -458,6 +458,7 @@ pt_BR = {
|
||||
|
||||
# Server messages to client
|
||||
"new-syncplay-available-motd-message": "Você está usando o Syncplay {}, mas uma versão mais nova está disponível em https://syncplay.pl", # ClientVersion
|
||||
"persistent-rooms-notice": "NOTICE: This server uses persistent rooms, which means that the playlist information is stored between playback sessions. If you want to create a room where information is not saved then put -temp at the end of the room name.", # TO DO: Translate - NOTE: Do not translate the word -temp
|
||||
|
||||
# Server notifications
|
||||
"welcome-server-notification": "Seja bem-vindo ao servidor de Syncplay, versão {0}", # version
|
||||
|
||||
@ -457,6 +457,7 @@ pt_PT = {
|
||||
|
||||
# Server messages to client
|
||||
"new-syncplay-available-motd-message": "Você está usando o Syncplay {}, mas uma versão mais nova está disponível em https://syncplay.pl", # ClientVersion
|
||||
"persistent-rooms-notice": "NOTICE: This server uses persistent rooms, which means that the playlist information is stored between playback sessions. If you want to create a room where information is not saved then put -temp at the end of the room name.", # TO DO: Translate - NOTE: Do not translate the word -temp
|
||||
|
||||
# Server notifications
|
||||
"welcome-server-notification": "Seja bem-vindo ao servidor de Syncplay, versão {0}", # version
|
||||
|
||||
@ -455,6 +455,7 @@ ru = {
|
||||
|
||||
# Server messages to client
|
||||
"new-syncplay-available-motd-message": "Вы используете Syncplay версии {}. Доступна более новая версия на https://syncplay.pl/", # ClientVersion
|
||||
"persistent-rooms-notice": "NOTICE: This server uses persistent rooms, which means that the playlist information is stored between playback sessions. If you want to create a room where information is not saved then put -temp at the end of the room name.", # TO DO: Translate - NOTE: Do not translate the word -temp
|
||||
|
||||
# Server notifications
|
||||
"welcome-server-notification": "Добро пожаловать на сервер Syncplay версии {0}", # version
|
||||
|
||||
@ -458,6 +458,7 @@ tr = {
|
||||
|
||||
# Server messages to client
|
||||
"new-syncplay-available-motd-message": "Syncplay {} kullanıyorsunuz ancak daha yeni bir sürüm https://syncplay.pl adresinde mevcut", # ClientVersion
|
||||
"persistent-rooms-notice": "NOTICE: This server uses persistent rooms, which means that the playlist information is stored between playback sessions. If you want to create a room where information is not saved then put -temp at the end of the room name.", # TO DO: Translate - NOTE: Do not translate the word -temp
|
||||
|
||||
# Server notifications
|
||||
"welcome-server-notification": "Syncplay sunucusuna hoş geldiniz, ver. {0}", # version
|
||||
|
||||
@ -131,6 +131,10 @@ class SyncClientProtocol(JSONCommandProtocol):
|
||||
self._client.setUsername(username)
|
||||
self._client.setRoom(roomName)
|
||||
self.logged = True
|
||||
if self.persistentRoomWarning(featureList):
|
||||
if len(motd) > 0:
|
||||
motd += "\n\n"
|
||||
motd += getMessage("persistent-rooms-notice")
|
||||
if motd:
|
||||
self._client.ui.showMessage(motd, True, True)
|
||||
self._client.ui.showMessage(getMessage("connected-successful-notification"))
|
||||
@ -138,6 +142,9 @@ class SyncClientProtocol(JSONCommandProtocol):
|
||||
self._client.sendFile()
|
||||
self._client.setServerVersion(version, featureList)
|
||||
|
||||
def persistentRoomWarning(self, serverFeatures):
|
||||
return serverFeatures["persistentRooms"] if "persistentRooms" in serverFeatures else False
|
||||
|
||||
def sendHello(self):
|
||||
hello = {}
|
||||
hello["username"] = self._client.getUsername()
|
||||
@ -441,6 +448,7 @@ class SyncServerProtocol(JSONCommandProtocol):
|
||||
self._features["featureList"] = False
|
||||
self._features["readiness"] = meetsMinVersion(self._version, USER_READY_MIN_VERSION)
|
||||
self._features["managedRooms"] = meetsMinVersion(self._version, CONTROLLED_ROOMS_MIN_VERSION)
|
||||
self._features["persistentRooms"] = False
|
||||
return self._features
|
||||
|
||||
def isLogged(self):
|
||||
@ -496,6 +504,11 @@ class SyncServerProtocol(JSONCommandProtocol):
|
||||
self._logged = True
|
||||
self.sendHello(version)
|
||||
|
||||
def persistentRoomWarning(self, clientFeatures, serverFeatures):
|
||||
serverPersistentRooms = serverFeatures["persistentRooms"]
|
||||
clientPersistentRooms = clientFeatures["persistentRooms"] if "persistentRooms" in clientFeatures else False
|
||||
return serverPersistentRooms and not clientPersistentRooms
|
||||
|
||||
@requireLogged
|
||||
def handleChat(self, chatMessage):
|
||||
if not self._factory.disableChat:
|
||||
@ -520,8 +533,12 @@ class SyncServerProtocol(JSONCommandProtocol):
|
||||
hello["room"] = {"name": room.getName()}
|
||||
hello["version"] = clientVersion # Used so 1.2.X client works on newer server
|
||||
hello["realversion"] = syncplay.version
|
||||
hello["motd"] = self._factory.getMotd(userIp, username, room, clientVersion)
|
||||
hello["features"] = self._factory.getFeatures()
|
||||
hello["motd"] = self._factory.getMotd(userIp, username, room, clientVersion)
|
||||
if self.persistentRoomWarning(clientFeatures=self._features, serverFeatures=hello["features"]):
|
||||
if len(hello["motd"]) > 0:
|
||||
hello["motd"] += "\n\n"
|
||||
hello["motd"] += getMessage("persistent-rooms-notice")
|
||||
self.sendMessage({"Hello": hello})
|
||||
|
||||
@requireLogged
|
||||
|
||||
@ -24,7 +24,6 @@ from syncplay.messages import getMessage
|
||||
from syncplay.protocols import SyncServerProtocol
|
||||
from syncplay.utils import RoomPasswordProvider, NotControlledRoom, RandomStringGenerator, meetsMinVersion, playlistIsValid, truncateText, getListAsMultilineString, convertMultilineStringToList
|
||||
|
||||
|
||||
class SyncFactory(Factory):
|
||||
def __init__(self, port='', password='', motdFilePath=None, roomsDbFile=None, permanentRoomsFile=None, isolateRooms=False, salt=None,
|
||||
disableReady=False, disableChat=False, maxChatMessageLength=constants.MAX_CHAT_MESSAGE_LENGTH,
|
||||
@ -93,6 +92,7 @@ class SyncFactory(Factory):
|
||||
features["isolateRooms"] = self.isolateRooms
|
||||
features["readiness"] = not self.disableReady
|
||||
features["managedRooms"] = True
|
||||
features["persistentRooms"] = self.roomsDbFile is not None
|
||||
features["chat"] = not self.disableChat
|
||||
features["maxChatMessageLength"] = self.maxChatMessageLength
|
||||
features["maxUsernameLength"] = self.maxUsernameLength
|
||||
@ -532,7 +532,10 @@ class Room(object):
|
||||
return self._roomsDbHandle is not None
|
||||
|
||||
def isPersistent(self):
|
||||
return self.roomsCanPersist()
|
||||
return self.roomsCanPersist() and not self.isMarkedAsTemporary()
|
||||
|
||||
def isMarkedAsTemporary(self):
|
||||
return "-temp" in self.getName()
|
||||
|
||||
def isPlaylistEmpty(self):
|
||||
return len(self._playlist) == 0
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user