-
Notifications
You must be signed in to change notification settings - Fork 88
Supermatter Engine / Multiauth #1015
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,18 +2,30 @@ | |
| using Content.Shared.Administration; | ||
| using Robust.Client.AutoGenerated; | ||
| using Robust.Client.GameObjects; | ||
| using Robust.Client.Player; | ||
| using Robust.Client.UserInterface.Controls; | ||
| using Robust.Client.UserInterface.XAML; | ||
| using Robust.Shared.Configuration; | ||
| using Robust.Shared.Network; | ||
| using Robust.Shared.Player; | ||
| using Robust.Shared.Utility; | ||
|
|
||
| namespace Content.Client.Administration.UI.CustomControls; | ||
|
|
||
| [GenerateTypedNameReferences] | ||
| public sealed partial class PlayerListEntry : BoxContainer | ||
| { | ||
| // WD EDIT START | ||
| private readonly ISharedPlayerManager _playerManager; | ||
| private readonly IConfigurationManager _config; | ||
| // WD EDIT END | ||
| public PlayerListEntry() | ||
| { | ||
| RobustXamlLoader.Load(this); | ||
| // WD EDIT START | ||
| _playerManager = IoCManager.Resolve<IPlayerManager>(); | ||
| _config = IoCManager.Resolve<IConfigurationManager>(); | ||
| // WD EDIT END | ||
| } | ||
|
|
||
| public event Action<PlayerInfo>? OnPinStatusChanged; | ||
|
|
@@ -36,8 +48,12 @@ public void Setup(PlayerInfo info, Func<PlayerInfo, string, string>? overrideTex | |
|
|
||
| private void Update(PlayerInfo info, Func<PlayerInfo, string, string>? overrideText) | ||
| { | ||
| PlayerEntryLabel.Text = overrideText?.Invoke(info, $"{info.CharacterName} ({info.Username})") ?? | ||
| $"{info.CharacterName} ({info.Username})"; | ||
| // WD EDIT START | ||
| PlayerEntryLabel.Text = overrideText?.Invoke( | ||
| info, | ||
| $"{info.CharacterName} ({info.Username}@{AuthServer.GetServerFromCVarListByUrl(_config, | ||
| _playerManager.GetSessionById(info.SessionId).Channel.UserData.AuthServer)?.Id})") ?? $"{info.CharacterName} ({info.Username})"; | ||
| // WD EDIT END | ||
|
Comment on lines
+51
to
+56
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Потенциальное NullReferenceException при получении сессии. Цепочка вызовов Рассмотрите добавление null-проверок или использование 🛠️ Предлагаемое исправление- PlayerEntryLabel.Text = overrideText?.Invoke(
- info,
- $"{info.CharacterName} ({info.Username}@{AuthServer.GetServerFromCVarListByUrl(_config,
- _playerManager.GetSessionById(info.SessionId).Channel.UserData.AuthServer)?.Id})") ?? $"{info.CharacterName} ({info.Username})";
+ var serverId = "Unknown";
+ if (_playerManager.TryGetSessionById(info.SessionId, out var session))
+ {
+ serverId = AuthServer.GetServerFromCVarListByUrl(_config, session.Channel.UserData.AuthServer)?.Id ?? "Unknown";
+ }
+ var displayName = $"{info.CharacterName} ({info.Username}@{serverId})";
+ PlayerEntryLabel.Text = overrideText?.Invoke(info, displayName) ?? $"{info.CharacterName} ({info.Username})"; |
||
|
|
||
| UpdatePinButtonTexture(info.IsPinned); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| using System.Collections.Immutable; | ||
| using System.Linq; | ||
| using System.Net; | ||
| using System.Net.Http; | ||
| using System.Net.Http.Headers; | ||
|
|
@@ -101,7 +102,7 @@ public PlayerLocator() | |
| return ReturnForPlayerRecord(record); | ||
|
|
||
| // If all else fails, ask the auth server. | ||
| var authServer = _configurationManager.GetCVar(CVars.AuthServer); | ||
| var authServer = AuthServer.FromStringList(_configurationManager.GetCVar(CVars.AuthServers)).First().AuthUrl; // WD EDIT | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Потенциальное исключение при пустом списке серверов аутентификации. Вызов 🛠️ Предлагаемое исправление- var authServer = AuthServer.FromStringList(_configurationManager.GetCVar(CVars.AuthServers)).First().AuthUrl; // WD EDIT
+ var authServers = AuthServer.FromStringList(_configurationManager.GetCVar(CVars.AuthServers));
+ var authServer = authServers.FirstOrDefault()?.AuthUrl
+ ?? throw new InvalidOperationException("No auth servers configured in CVars.AuthServers"); // WD EDIT🤖 Prompt for AI Agents |
||
| var requestUri = $"{authServer}api/query/name?name={WebUtility.UrlEncode(playerName)}"; | ||
| using var resp = await _httpClient.GetAsync(requestUri, cancel); | ||
|
|
||
|
|
@@ -120,7 +121,7 @@ public PlayerLocator() | |
| return ReturnForPlayerRecord(record); | ||
|
|
||
| // If all else fails, ask the auth server. | ||
| var authServer = _configurationManager.GetCVar(CVars.AuthServer); | ||
| var authServer = AuthServer.FromStringList(_configurationManager.GetCVar(CVars.AuthServers)).First().AuthUrl; // WD EDIT | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Дублирование проблемы с Аналогичная проблема с вызовом ♻️ Предлагаемый рефакторинг — вынести в отдельный метод+ private string GetPrimaryAuthServerUrl()
+ {
+ var authServers = AuthServer.FromStringList(_configurationManager.GetCVar(CVars.AuthServers));
+ return authServers.FirstOrDefault()?.AuthUrl
+ ?? throw new InvalidOperationException("No auth servers configured");
+ }Затем использовать: - var authServer = AuthServer.FromStringList(_configurationManager.GetCVar(CVars.AuthServers)).First().AuthUrl; // WD EDIT
+ var authServer = GetPrimaryAuthServerUrl(); // WD EDIT🤖 Prompt for AI Agents |
||
| var requestUri = $"{authServer}api/query/userid?userid={WebUtility.UrlEncode(userId.UserId.ToString())}"; | ||
| using var resp = await _httpClient.GetAsync(requestUri, cancel); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -13,6 +13,7 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||
| using Content.Shared.Database; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| using Content.Shared.Mind; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| using Content.Shared.Players.RateLimiting; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| using Robust.Shared; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| using Robust.Shared.Configuration; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| using Robust.Shared.Network; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| using Robust.Shared.Player; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -248,15 +249,35 @@ private void SendOOC(ICommonSession player, string message) | |||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| Color? colorOverride = null; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| var wrappedMessage = Loc.GetString("chat-manager-send-ooc-wrap-message", ("playerName",player.Name), ("message", FormattedMessage.EscapeText(message))); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| // WD EDDIT START | ||||||||||||||||||||||||||||||||||||||||||||||||||
| var authServer = player.AuthType == LoginType.LoggedIn | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ? AuthServer.FromStringList(_configurationManager.GetCVar(CVars.AuthServers)) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| .FirstOrDefault(x => x.AuthUrl.ToString() == player.Channel.UserData.AuthServer) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ?.Id ?? "Unknown" | ||||||||||||||||||||||||||||||||||||||||||||||||||
| : "Unknown"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| var wrappedMessage = Loc.GetString( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| "chat-manager-send-ooc-wrap-message", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ("playerName", $"{player.Name}"), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ("authServer", authServer), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ("message", FormattedMessage.EscapeText(message))); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| // WD EDIT END | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+253
to
+264
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Логика определения authServer корректна, но есть опечатка в комментарии. Реализация с использованием 🔧 Исправление опечатки- // WD EDDIT START
+ // WD EDIT START📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| if (_adminManager.HasAdminFlag(player, AdminFlags.Admin)) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| var prefs = _preferencesManager.GetPreferences(player.UserId); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| colorOverride = prefs.AdminOOCColor; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| if ( _netConfigManager.GetClientCVar(player.Channel, CCVars.ShowOocPatronColor) && player.Channel.UserData.PatronTier is { } patron && PatronOocColors.TryGetValue(patron, out var patronColor)) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| wrappedMessage = Loc.GetString("chat-manager-send-ooc-patron-wrap-message", ("patronColor", patronColor),("playerName", player.Name), ("message", FormattedMessage.EscapeText(message))); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| // WD EDIT START | ||||||||||||||||||||||||||||||||||||||||||||||||||
| wrappedMessage = Loc.GetString( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| "chat-manager-send-ooc-patron-wrap-message", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ("patronColor", patronColor), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ("playerName", player.Name), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ("authServer", authServer), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ("message", FormattedMessage.EscapeText(message))); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| // WD EDIT END | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| //TODO: player.Name color, this will need to change the structure of the MsgChatMessage | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Потенциальное NullReferenceException при получении сессии (аналогично PlayerListEntry).
Та же проблема, что и в
PlayerListEntry.xaml.cs— цепочка вызовов_playerManager.GetSessionById(...).Channel.UserData.AuthServerможет выбросить исключение.🛠️ Предлагаемое исправление
🤖 Prompt for AI Agents