Handle incoming MAX call events
This commit is contained in:
@@ -2,8 +2,15 @@ namespace QMax.Api.Services;
|
||||
|
||||
public static class MessageTextSanitizer
|
||||
{
|
||||
private const string IncomingCallText = "\u0412\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u0437\u0432\u043e\u043d\u043e\u043a";
|
||||
|
||||
public static string? CleanChatPreview(string? value)
|
||||
{
|
||||
if (IsCallMediaLabel(value))
|
||||
{
|
||||
return IncomingCallText;
|
||||
}
|
||||
|
||||
if (IsGenericMediaLabel(value))
|
||||
{
|
||||
return "\u041c\u0435\u0434\u0438\u0430";
|
||||
@@ -16,6 +23,11 @@ public static class MessageTextSanitizer
|
||||
|
||||
public static string? CleanMessageText(string? value, bool hasAttachments)
|
||||
{
|
||||
if (IsCallMediaLabel(value))
|
||||
{
|
||||
return IncomingCallText;
|
||||
}
|
||||
|
||||
if (hasAttachments && IsGenericAttachmentLabel(value))
|
||||
{
|
||||
return null;
|
||||
@@ -60,6 +72,13 @@ public static class MessageTextSanitizer
|
||||
};
|
||||
}
|
||||
|
||||
public static bool IsCallMediaLabel(string? value)
|
||||
{
|
||||
var text = value?.Trim();
|
||||
return string.Equals(text, "call", StringComparison.OrdinalIgnoreCase) ||
|
||||
text?.StartsWith("call-", StringComparison.OrdinalIgnoreCase) == true;
|
||||
}
|
||||
|
||||
public static bool IsGenericAttachmentLabel(string? value)
|
||||
{
|
||||
if (IsGenericMediaLabel(value))
|
||||
|
||||
Reference in New Issue
Block a user