[backend/masto-client] Fix public media url handling
This commit is contained in:
parent
18bcba7e30
commit
4c3a140e9f
3 changed files with 7 additions and 26 deletions
|
@ -43,26 +43,11 @@ public class NoteRenderer(
|
|||
var noteEmoji = data?.Emoji?.Where(p => note.Emojis.Contains(p.Id)).ToList() ?? await GetEmoji([note]);
|
||||
|
||||
var mentions = data?.Mentions == null
|
||||
? await db.Users.IncludeCommonProperties()
|
||||
.Where(p => note.Mentions.Contains(p.Id))
|
||||
.Select(u => new MentionEntity(u, config.Value.WebDomain))
|
||||
.ToListAsync()
|
||||
? await GetMentions([note])
|
||||
: [..data.Mentions.Where(p => note.Mentions.Contains(p.Id))];
|
||||
|
||||
var attachments = data?.Attachments == null
|
||||
? await db.DriveFiles.Where(p => note.FileIds.Contains(p.Id))
|
||||
.Select(f => new AttachmentEntity
|
||||
{
|
||||
Id = f.Id,
|
||||
Url = f.WebpublicUrl ?? f.Url,
|
||||
Blurhash = f.Blurhash,
|
||||
PreviewUrl = f.ThumbnailUrl,
|
||||
Description = f.Comment,
|
||||
Metadata = null,
|
||||
RemoteUrl = f.Uri,
|
||||
Type = AttachmentEntity.GetType(f.Type)
|
||||
})
|
||||
.ToListAsync()
|
||||
? await GetAttachments([note])
|
||||
: [..data.Attachments.Where(p => note.FileIds.Contains(p.Id))];
|
||||
|
||||
|
||||
|
@ -132,9 +117,9 @@ public class NoteRenderer(
|
|||
.Select(f => new AttachmentEntity
|
||||
{
|
||||
Id = f.Id,
|
||||
Url = f.Url,
|
||||
Url = f.PublicUrl,
|
||||
Blurhash = f.Blurhash,
|
||||
PreviewUrl = f.ThumbnailUrl,
|
||||
PreviewUrl = f.PublicThumbnailUrl,
|
||||
Description = f.Comment,
|
||||
Metadata = null,
|
||||
RemoteUrl = f.Uri,
|
||||
|
|
|
@ -189,6 +189,9 @@ public class DriveFile : IEntity
|
|||
[StringLength(32)]
|
||||
public string Id { get; set; } = null!;
|
||||
|
||||
[NotMapped] public string PublicUrl => WebpublicUrl ?? Url;
|
||||
[NotMapped] public string PublicThumbnailUrl => ThumbnailUrl ?? WebpublicUrl ?? Url;
|
||||
|
||||
public class FileProperties
|
||||
{
|
||||
[J("width")] public int? Width { get; set; }
|
||||
|
|
|
@ -296,13 +296,6 @@ public class DriveService(
|
|||
await queueSvc.BackgroundTaskQueue.EnqueueAsync(job);
|
||||
}
|
||||
|
||||
public string GetPublicUrl(DriveFile file, bool thumbnail)
|
||||
{
|
||||
return thumbnail
|
||||
? file.ThumbnailUrl ?? file.WebpublicUrl ?? file.Url
|
||||
: file.WebpublicUrl ?? file.Url;
|
||||
}
|
||||
|
||||
private static string GenerateFilenameKeepingExtension(string filename)
|
||||
{
|
||||
var guid = Guid.NewGuid().ToString().ToLowerInvariant();
|
||||
|
|
Loading…
Add table
Reference in a new issue