[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 noteEmoji = data?.Emoji?.Where(p => note.Emojis.Contains(p.Id)).ToList() ?? await GetEmoji([note]);
|
||||||
|
|
||||||
var mentions = data?.Mentions == null
|
var mentions = data?.Mentions == null
|
||||||
? await db.Users.IncludeCommonProperties()
|
? await GetMentions([note])
|
||||||
.Where(p => note.Mentions.Contains(p.Id))
|
|
||||||
.Select(u => new MentionEntity(u, config.Value.WebDomain))
|
|
||||||
.ToListAsync()
|
|
||||||
: [..data.Mentions.Where(p => note.Mentions.Contains(p.Id))];
|
: [..data.Mentions.Where(p => note.Mentions.Contains(p.Id))];
|
||||||
|
|
||||||
var attachments = data?.Attachments == null
|
var attachments = data?.Attachments == null
|
||||||
? await db.DriveFiles.Where(p => note.FileIds.Contains(p.Id))
|
? await GetAttachments([note])
|
||||||
.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()
|
|
||||||
: [..data.Attachments.Where(p => note.FileIds.Contains(p.Id))];
|
: [..data.Attachments.Where(p => note.FileIds.Contains(p.Id))];
|
||||||
|
|
||||||
|
|
||||||
|
@ -132,9 +117,9 @@ public class NoteRenderer(
|
||||||
.Select(f => new AttachmentEntity
|
.Select(f => new AttachmentEntity
|
||||||
{
|
{
|
||||||
Id = f.Id,
|
Id = f.Id,
|
||||||
Url = f.Url,
|
Url = f.PublicUrl,
|
||||||
Blurhash = f.Blurhash,
|
Blurhash = f.Blurhash,
|
||||||
PreviewUrl = f.ThumbnailUrl,
|
PreviewUrl = f.PublicThumbnailUrl,
|
||||||
Description = f.Comment,
|
Description = f.Comment,
|
||||||
Metadata = null,
|
Metadata = null,
|
||||||
RemoteUrl = f.Uri,
|
RemoteUrl = f.Uri,
|
||||||
|
|
|
@ -189,6 +189,9 @@ public class DriveFile : IEntity
|
||||||
[StringLength(32)]
|
[StringLength(32)]
|
||||||
public string Id { get; set; } = null!;
|
public string Id { get; set; } = null!;
|
||||||
|
|
||||||
|
[NotMapped] public string PublicUrl => WebpublicUrl ?? Url;
|
||||||
|
[NotMapped] public string PublicThumbnailUrl => ThumbnailUrl ?? WebpublicUrl ?? Url;
|
||||||
|
|
||||||
public class FileProperties
|
public class FileProperties
|
||||||
{
|
{
|
||||||
[J("width")] public int? Width { get; set; }
|
[J("width")] public int? Width { get; set; }
|
||||||
|
|
|
@ -296,13 +296,6 @@ public class DriveService(
|
||||||
await queueSvc.BackgroundTaskQueue.EnqueueAsync(job);
|
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)
|
private static string GenerateFilenameKeepingExtension(string filename)
|
||||||
{
|
{
|
||||||
var guid = Guid.NewGuid().ToString().ToLowerInvariant();
|
var guid = Guid.NewGuid().ToString().ToLowerInvariant();
|
||||||
|
|
Loading…
Add table
Reference in a new issue