Skip to content

Commit 2487616

Browse files
committed
Limit incoming messages to 2k messages like Signal-Android
1 parent 96bd4da commit 2487616

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

Signal-Windows.Lib/IncomingMessages.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ private async Task HandleSignalMessage(SignalServiceEnvelope envelope, SignalSer
621621
Direction = type,
622622
Status = status,
623623
Author = author,
624-
Content = new SignalMessageContent() { Content = body },
624+
Content = new SignalMessageContent() { Content = body.Truncate(2000) },
625625
ThreadId = conversation.ThreadId,
626626
DeviceId = (uint)envelope.GetSourceDevice(),
627627
Receipts = 0,

Signal-Windows.Lib/Util/LibUtils.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,4 +115,13 @@ public static FileStream CreateTmpFile(string name)
115115
return File.Open(ApplicationData.Current.LocalCacheFolder.Path + Path.AltDirectorySeparatorChar + name, FileMode.Create, FileAccess.ReadWrite);
116116
}
117117
}
118+
119+
public static class StringExt
120+
{
121+
public static string Truncate(this string value, int maxLength) // thanks to https://stackoverflow.com/a/2776689/1569755
122+
{
123+
if (string.IsNullOrEmpty(value)) return value;
124+
return value.Length <= maxLength ? value : value.Substring(0, maxLength);
125+
}
126+
}
118127
}

0 commit comments

Comments
 (0)