Add CVars for privacy policy information (#5545)

* Add CVars for privacy policy information

Engine side of https://github.com/space-wizards/SS14.Launcher/issues/194

* Improve/fix cvar desc
This commit is contained in:
Pieter-Jan Briers
2024-12-08 23:48:50 +01:00
committed by GitHub
parent 1621d25a92
commit aca7847933
2 changed files with 53 additions and 0 deletions

View File

@@ -103,6 +103,22 @@ namespace Robust.Server.ServerStatus
["desc"] = _serverDescCache,
};
var privacyPolicyLink = _cfg.GetCVar(CVars.StatusPrivacyPolicyLink);
var privacyPolicyIdentifier = _cfg.GetCVar(CVars.StatusPrivacyPolicyIdentifier);
var privacyPolicyVersion = _cfg.GetCVar(CVars.StatusPrivacyPolicyVersion);
if (!string.IsNullOrEmpty(privacyPolicyLink)
&& !string.IsNullOrEmpty(privacyPolicyIdentifier)
&& !string.IsNullOrEmpty(privacyPolicyVersion))
{
jObject["privacy_policy"] = new JsonObject
{
["identifier"] = privacyPolicyIdentifier,
["version"] = privacyPolicyVersion,
["link"] = privacyPolicyLink,
};
}
OnInfoRequest?.Invoke(jObject);
await context.RespondJsonAsync(jObject);

View File

@@ -628,6 +628,43 @@ namespace Robust.Shared
public static readonly CVarDef<string> StatusConnectAddress =
CVarDef.Create("status.connectaddress", "", CVar.ARCHIVE | CVar.SERVERONLY);
/// <summary>
/// HTTP(S) link to a privacy policy that the user must accept to connect to the server.
/// </summary>
/// <remarks>
/// This must be set along with <see cref="StatusPrivacyPolicyIdentifier"/> and
/// <see cref="StatusPrivacyPolicyVersion"/> for the user to be prompted about a privacy policy.
/// </remarks>
public static readonly CVarDef<string> StatusPrivacyPolicyLink =
CVarDef.Create("status.privacy_policy_link", "https://example.com/privacy", CVar.SERVER | CVar.REPLICATED);
/// <summary>
/// An identifier for privacy policy specified by <see cref="StatusPrivacyPolicyLink"/>.
/// This must be globally unique.
/// </summary>
/// <remarks>
/// <para>
/// This value must be globally unique per server community. Servers that want to enforce a
/// privacy policy should set this to a value that is unique to their server and, preferably, recognizable.
/// </para>
/// <para>
/// This value is stored by the launcher to keep track of what privacy policies a player has accepted.
/// </para>
/// </remarks>
public static readonly CVarDef<string> StatusPrivacyPolicyIdentifier =
CVarDef.Create("status.privacy_policy_identifier", "", CVar.SERVER | CVar.REPLICATED);
/// <summary>
/// A "version" for the privacy policy specified by <see cref="StatusPrivacyPolicyLink"/>.
/// </summary>
/// <remarks>
/// <para>
/// This parameter is stored by the launcher and should be modified whenever your server's privacy policy changes.
/// </para>
/// </remarks>
public static readonly CVarDef<string> StatusPrivacyPolicyVersion =
CVarDef.Create("status.privacy_policy_version", "", CVar.SERVER | CVar.REPLICATED);
/*
* BUILD
*/