Fix voice message forwarding and playback
This commit is contained in:
@@ -7,6 +7,7 @@ using Microsoft.Extensions.Options;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using QMax.Api.Configuration;
|
||||
using QMax.Api.Data;
|
||||
using QMax.Api.Data.Entities;
|
||||
using QMax.Api.Infrastructure.Auth;
|
||||
using QMax.Api.Infrastructure.Hubs;
|
||||
using QMax.Api.Infrastructure.Max;
|
||||
@@ -234,6 +235,27 @@ static async Task EnsureCompatibilitySchemaAsync(QMaxDbContext db)
|
||||
await db.Database.ExecuteSqlRawAsync("ALTER TABLE Chats ADD COLUMN PendingMaxActionError TEXT;");
|
||||
}
|
||||
|
||||
var messageColumns = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
||||
await using (var command = connection.CreateCommand())
|
||||
{
|
||||
command.CommandText = "PRAGMA table_info(Messages);";
|
||||
await using var reader = await command.ExecuteReaderAsync();
|
||||
while (await reader.ReadAsync())
|
||||
{
|
||||
messageColumns.Add(reader.GetString(1));
|
||||
}
|
||||
}
|
||||
|
||||
if (!messageColumns.Contains("ForwardedFromExternalChatId"))
|
||||
{
|
||||
await db.Database.ExecuteSqlRawAsync("ALTER TABLE Messages ADD COLUMN ForwardedFromExternalChatId TEXT;");
|
||||
}
|
||||
|
||||
if (!messageColumns.Contains("ForwardedFromExternalMessageId"))
|
||||
{
|
||||
await db.Database.ExecuteSqlRawAsync("ALTER TABLE Messages ADD COLUMN ForwardedFromExternalMessageId TEXT;");
|
||||
}
|
||||
|
||||
var attachmentColumns = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
||||
await using (var command = connection.CreateCommand())
|
||||
{
|
||||
@@ -385,6 +407,22 @@ static async Task RemoveGenericMediaLabelsAsync(QMaxDbContext db)
|
||||
var attachments = await db.MessageAttachments.ToListAsync();
|
||||
foreach (var attachment in attachments)
|
||||
{
|
||||
if (attachment.Kind == AttachmentKind.File)
|
||||
{
|
||||
var inferredKind = AttachmentStorageService.GuessKind(
|
||||
attachment.ContentType,
|
||||
Path.GetExtension(attachment.OriginalFileName));
|
||||
if (inferredKind != AttachmentKind.File)
|
||||
{
|
||||
attachment.Kind = inferredKind;
|
||||
}
|
||||
}
|
||||
|
||||
attachment.ContentType = AttachmentStorageService.NormalizeContentType(
|
||||
attachment.ContentType,
|
||||
attachment.OriginalFileName,
|
||||
attachment.Kind);
|
||||
|
||||
var normalizedFileName = AttachmentStorageService.NormalizeRemoteFileName(
|
||||
attachment.OriginalFileName,
|
||||
attachment.ContentType,
|
||||
|
||||
Reference in New Issue
Block a user