Fix typing indicator input validation. (#10818)

This commit is contained in:
Leon Friedrich
2022-08-26 01:44:43 +12:00
committed by GitHub
parent 6237b784c2
commit 1e9e93a33c
3 changed files with 13 additions and 15 deletions

View File

@@ -1,6 +1,7 @@
using Content.Shared.ActionBlocker;
using Content.Shared.Chat.TypingIndicator;
using Robust.Server.GameObjects;
using Robust.Shared.Players;
namespace Content.Server.Chat.TypingIndicator;
@@ -33,24 +34,24 @@ public sealed class TypingIndicatorSystem : SharedTypingIndicatorSystem
SetTypingIndicatorEnabled(uid, false);
}
private void OnClientTypingChanged(TypingChangedEvent ev)
private void OnClientTypingChanged(TypingChangedEvent ev, EntitySessionEventArgs args)
{
// make sure that this entity still exist
if (!Exists(ev.Uid))
var uid = args.SenderSession.AttachedEntity;
if (!Exists(uid))
{
Logger.Warning($"Client attached entity {ev.Uid} from TypingChangedEvent doesn't exist on server.");
Logger.Warning($"Client {args.SenderSession} sent TypingChangedEvent without an attached entity.");
return;
}
// check if this entity can speak or emote
if (!_actionBlocker.CanEmote(ev.Uid) && !_actionBlocker.CanSpeak(ev.Uid))
if (!_actionBlocker.CanEmote(uid.Value) && !_actionBlocker.CanSpeak(uid.Value))
{
// nah, make sure that typing indicator is disabled
SetTypingIndicatorEnabled(ev.Uid, false);
SetTypingIndicatorEnabled(uid.Value, false);
return;
}
SetTypingIndicatorEnabled(ev.Uid, ev.IsTyping);
SetTypingIndicatorEnabled(uid.Value, ev.IsTyping);
}
private void SetTypingIndicatorEnabled(EntityUid uid, bool isEnabled, AppearanceComponent? appearance = null)