preprocess logiin welcome msg

This commit is contained in:
UbitUmarov
2024-04-28 12:51:31 +01:00
parent 034cf66dfe
commit 020ddeef65
2 changed files with 35 additions and 49 deletions

View File

@@ -270,7 +270,6 @@ namespace OpenSim.Services.LLLoginService
m_log.DebugFormat("[LOGIN RESPONSE] LLLoginResponse create. sizeX={0}, sizeY={1}", RegionSizeX, RegionSizeY);
FillOutSeedCap(aCircuit, destination, clientIP);
switch (DSTZone)
{
case "none":
@@ -306,7 +305,6 @@ namespace OpenSim.Services.LLLoginService
{
DST = dstTimeZone.IsDaylightSavingTime(DateTime.Now) ? "Y" : "N";
}
break;
}
}
@@ -406,30 +404,7 @@ namespace OpenSim.Services.LLLoginService
private void SetDefaultValues()
{
TimeZoneInfo gridTimeZone;
// Disabled for now pending making timezone a config value, which can at some point have a default of
// a ; separated list of possible timezones.
// The problem here is that US/Pacific (or even the Olsen America/Los_Angeles) is not universal across
// windows, mac and various distributions of linux, introducing another element of consistency.
// The server operator needs to be able to control this setting
// try
// {
// // First try to fetch DST from Pacific Standard Time, because this is
// // the one expected by the viewer. "US/Pacific" is the string to search
// // on linux and mac, and should work also on Windows (to confirm)
// gridTimeZone = TimeZoneInfo.FindSystemTimeZoneById("US/Pacific");
// }
// catch (Exception e)
// {
// m_log.WarnFormat(
// "[TIMEZONE]: {0} Falling back to system time. System time should be set to Pacific Standard Time to provide the expected time",
// e.Message);
gridTimeZone = TimeZoneInfo.Local;
// }
DST = gridTimeZone.IsDaylightSavingTime(DateTime.Now) ? "Y" : "N";
DST = "N";
StipendSinceLogin = "N";
Gendered = "Y";
@@ -494,7 +469,7 @@ namespace OpenSim.Services.LLLoginService
currency = String.Empty;
ClassifiedFee = "0";
MaxAgentGroups = 42;
MaxAgentGroups = Constants.MaxAgentGroups;
}

View File

@@ -90,6 +90,7 @@ namespace OpenSim.Services.LLLoginService
protected string m_DeniedID0s;
protected string m_MessageUrl;
protected string m_DSTZone;
protected bool m_allowDuplicatePresences = false;
protected string m_messageKey;
protected bool m_allowLoginFallbackToAnyRegion = true; // if login requested region if not found and there are no Default or fallback regions,
@@ -166,11 +167,32 @@ namespace OpenSim.Services.LLLoginService
m_DeniedID0s = Util.GetConfigVarFromSections<string>(config, "DeniedID0s", accessControlConfigSections, string.Empty);
m_MessageUrl = m_LoginServerConfig.GetString("MessageUrl", string.Empty);
m_WelcomeMessage = null;
if (!string.IsNullOrEmpty(m_MessageUrl))
{
try
{
using (WebClient client = new())
m_WelcomeMessage = client.DownloadString(m_MessageUrl);
}
catch
{
m_WelcomeMessage = null;
}
}
if (string.IsNullOrEmpty(m_WelcomeMessage))
m_WelcomeMessage = m_LoginServerConfig.GetString("WelcomeMessage", "Welcome to OpenSim!");
m_WelcomeMessage = m_WelcomeMessage.Replace("\\n", "\n");
m_DSTZone = m_LoginServerConfig.GetString("DSTZone", "America/Los_Angeles;Pacific Standard Time");
m_MaxAgentGroups = Constants.MaxAgentGroups;
IConfig groupConfig = config.Configs["Groups"];
if (groupConfig is not null)
m_MaxAgentGroups = groupConfig.GetInt("MaxAgentGroups", 42);
m_MaxAgentGroups = groupConfig.GetInt("MaxAgentGroups", m_MaxAgentGroups);
IConfig presenceConfig = config.Configs["PresenceService"];
if (presenceConfig is not null)
@@ -193,10 +215,7 @@ namespace OpenSim.Services.LLLoginService
if (accountService.Length == 0 || authService.Length == 0)
throw new Exception("LoginService is missing service specifications");
// replace newlines in welcome message
m_WelcomeMessage = m_WelcomeMessage.Replace("\\n", "\n");
object[] args = new object[] { config };
object[] args = [config];
m_UserAccountService = ServerUtils.LoadPlugin<IUserAccountService>(accountService, args);
m_GridUserService = ServerUtils.LoadPlugin<IGridUserService>(gridUserService, args);
object[] authArgs = new object[] { config, m_UserAccountService };
@@ -478,7 +497,7 @@ namespace OpenSim.Services.LLLoginService
m_HGInventoryService?.GetRootFolder(account.PrincipalID);
List<InventoryFolderBase> inventorySkel = m_InventoryService.GetInventorySkeleton(account.PrincipalID);
if (m_RequireInventory && ((inventorySkel is null) || (inventorySkel is not null && inventorySkel.Count == 0)))
if (m_RequireInventory && inventorySkel is null || inventorySkel.Count == 0)
{
m_log.InfoFormat(
"[LLOGIN SERVICE]: Login failed, for {0} {1}, reason: unable to retrieve user inventory",
@@ -486,10 +505,6 @@ namespace OpenSim.Services.LLLoginService
return LLFailedLoginResponse.InventoryProblem;
}
// Get active gestures
List<InventoryItemBase> gestures = m_InventoryService.GetActiveGestures(account.PrincipalID);
// m_log.DebugFormat("[LLOGIN SERVICE]: {0} active gestures", gestures.Count);
//
// Login the presence
//
@@ -599,22 +614,17 @@ namespace OpenSim.Services.LLLoginService
if (m_FriendsService is not null)
{
friendsList = m_FriendsService.GetFriends(account.PrincipalID);
// m_log.DebugFormat("[LLOGIN SERVICE]: Retrieved {0} friends", friendsList.Length);
//m_log.DebugFormat("[LLOGIN SERVICE]: Retrieved {0} friends", friendsList.Length);
}
//
// Finally, fill out the response and return it
//
if (m_MessageUrl != string.Empty)
{
using(WebClient client = new())
processedMessage = client.DownloadString(m_MessageUrl);
}
else
{
processedMessage = m_WelcomeMessage;
}
processedMessage = processedMessage.Replace("\\n", "\n").Replace("<USERNAME>", firstName + " " + lastName);
processedMessage = m_WelcomeMessage.Replace("<USERNAME>", firstName + " " + lastName);
// Get active gestures
List<InventoryItemBase> gestures = m_InventoryService.GetActiveGestures(account.PrincipalID);
//m_log.DebugFormat("[LLOGIN SERVICE]: {0} active gestures", gestures.Count);
LLLoginResponse response = new(
account, aCircuit, guinfo, destination, inventorySkel, friendsList, m_LibraryService,
@@ -1157,6 +1167,7 @@ namespace OpenSim.Services.LLLoginService
{
m_WelcomeMessage = cmd[2];
MainConsole.Instance.Output("Login welcome message set to '{0}'", m_WelcomeMessage);
m_WelcomeMessage = m_WelcomeMessage.Replace("\\n", "\n");
}
break;
}