Skip to content
This repository has been archived by the owner on Oct 25, 2023. It is now read-only.

Commit

Permalink
cap mass media articles (#202)
Browse files Browse the repository at this point in the history
no more 500px wide images
  • Loading branch information
BasedUser authored Sep 29, 2023
1 parent b1bf172 commit fb9eaeb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Content.Client/MassMedia/Ui/NewsWriteBoundUserInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ private void OnShareButtonPressed()
var stringName = _menu.NameInput.Text;
var name = (stringName.Length <= 25 ? stringName.Trim() : $"{stringName.Trim().Substring(0, 25)}...");
article.Name = name;
article.Content = stringContent;
article.Content = stringContent.Substring(0, Math.Min(stringContent.Length, 32768));
article.ShareTime = _gameTiming.CurTime.Subtract(_gameTicker.RoundStartTimeSpan);

_menu.ContentInput.TextRope = new Rope.Leaf(string.Empty);
Expand Down
16 changes: 16 additions & 0 deletions Content.Server/MassMedia/Systems/NewsSystem.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
using Content.Server.Administration.Logs;
using Content.Server.Chat.Managers;
using Content.Server.MassMedia.Components;
using Content.Server.PDA.Ringer;
using Content.Shared.Access.Components;
using Content.Shared.Access.Systems;
using Content.Shared.Database;
using Content.Shared.GameTicking;
using Content.Shared.MassMedia.Components;
using Content.Shared.MassMedia.Systems;
Expand All @@ -26,6 +29,8 @@ public sealed class NewsSystem : EntitySystem
[Dependency] private readonly CartridgeLoaderSystem? _cartridgeLoaderSystem = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly PopupSystem _popup = default!;
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
[Dependency] private readonly IChatManager _chat = default!;

[Dependency] private readonly AccessReaderSystem _accessReader = default!;

Expand Down Expand Up @@ -113,6 +118,17 @@ public void OnWriteUiShareMessage(EntityUid uid, NewsWriteComponent component, N
&& _accessReader.FindAccessItemsInventory(author.Value, out var items)
&& _accessReader.FindStationRecordKeys(author.Value, out var stationRecordKeys, items))
{
if (article.Content.Length > 8192) {
if (article.Content.Length > 32768) {
_adminLogger.Add(LogType.Action, LogImpact.Extreme, $"{ToPrettyString(author.Value):player} has sent a news article above the size limit ({article.Content.Length} > 32768 characters long).");
_chat.SendAdminAlert(author.Value, $"has sent a news article above the size limit ({article.Content.Length} > 32768 characters long).");
article.Content = msg.Article.Content.Substring(0, 32768);
}
else {
_adminLogger.Add(LogType.Action, LogImpact.High, $"{ToPrettyString(author.Value):player} has sent a large news article ({article.Content.Length} > 8192 characters long).");
_chat.SendAdminAlert(author.Value, $"has sent a large news article ({article.Content.Length} characters long).");
}
}
article.AuthorStationRecordKeyIds = stationRecordKeys;

foreach (var item in items)
Expand Down

0 comments on commit fb9eaeb

Please sign in to comment.