Skip to content

Commit

Permalink
Add CVars for privacy policy information (#5545)
Browse files Browse the repository at this point in the history
* Add CVars for privacy policy information

Engine side of space-wizards/SS14.Launcher#194

* Improve/fix cvar desc
  • Loading branch information
PJB3005 authored Dec 8, 2024
1 parent 1621d25 commit aca7847
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Robust.Server/ServerStatus/StatusHost.Handlers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,22 @@ private async Task<bool> HandleInfo(IStatusHandlerContext context)
["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);
Expand Down
37 changes: 37 additions & 0 deletions Robust.Shared/CVars.cs
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,43 @@ protected CVars()
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
*/
Expand Down

0 comments on commit aca7847

Please sign in to comment.