[backend/federation] Federate alt text (ISH-55)
This commit is contained in:
parent
8c015815bc
commit
b67dd173f4
5 changed files with 12 additions and 5 deletions
|
@ -72,7 +72,6 @@ public class DriveFile : IEntity {
|
|||
/// The comment of the DriveFile.
|
||||
/// </summary>
|
||||
[Column("comment")]
|
||||
[StringLength(8192)]
|
||||
public string? Comment { get; set; }
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -56,7 +56,8 @@ public class NoteRenderer(IOptions<Config.InstanceSection> config, MfmConverter
|
|||
Type = $"{Constants.ActivityStreamsNs}#Document",
|
||||
Sensitive = p.IsSensitive,
|
||||
Url = new ASObjectBase(p.Url),
|
||||
MediaType = p.Type
|
||||
MediaType = p.Type,
|
||||
Description = p.Comment
|
||||
})
|
||||
.Cast<ASAttachment>()
|
||||
.ToListAsync()
|
||||
|
|
|
@ -24,6 +24,10 @@ public class ASDocument : ASAttachment {
|
|||
[J("https://www.w3.org/ns/activitystreams#sensitive")]
|
||||
[JC(typeof(ValueObjectConverter))]
|
||||
public bool? Sensitive { get; set; }
|
||||
|
||||
[J("https://www.w3.org/ns/activitystreams#name")]
|
||||
[JC(typeof(ValueObjectConverter))]
|
||||
public string? Description { get; set; }
|
||||
}
|
||||
|
||||
public sealed class ASAttachmentConverter : JsonConverter {
|
||||
|
|
|
@ -23,7 +23,9 @@ public class DriveService(
|
|||
QueueService queueSvc,
|
||||
ILogger<DriveService> logger
|
||||
) {
|
||||
public async Task<DriveFile?> StoreFile(string? uri, User user, bool sensitive) {
|
||||
public async Task<DriveFile?> StoreFile(
|
||||
string? uri, User user, bool sensitive, string? description = null, string? mimeType = null
|
||||
) {
|
||||
if (uri == null) return null;
|
||||
|
||||
logger.LogDebug("Storing file {uri} for user {userId}", uri, user.Id);
|
||||
|
@ -63,7 +65,8 @@ public class DriveService(
|
|||
Uri = uri,
|
||||
Filename = new Uri(uri).AbsolutePath.Split('/').LastOrDefault() ?? "",
|
||||
IsSensitive = sensitive,
|
||||
MimeType = CleanMimeType(res.Content.Headers.ContentType?.MediaType)
|
||||
Comment = description,
|
||||
MimeType = CleanMimeType(mimeType ?? res.Content.Headers.ContentType?.MediaType)
|
||||
};
|
||||
|
||||
return await StoreFile(await res.Content.ReadAsStreamAsync(), user, request);
|
||||
|
|
|
@ -283,7 +283,7 @@ public class NoteService(
|
|||
if (attachments is not { Count: > 0 }) return [];
|
||||
var result = await attachments
|
||||
.OfType<ASDocument>()
|
||||
.Select(p => driveSvc.StoreFile(p.Url?.Id, user, p.Sensitive ?? sensitive))
|
||||
.Select(p => driveSvc.StoreFile(p.Url?.Id, user, p.Sensitive ?? sensitive, p.Description, p.MediaType))
|
||||
.AwaitAllNoConcurrencyAsync();
|
||||
|
||||
return result.Where(p => p != null).Cast<DriveFile>().ToList();
|
||||
|
|
Loading…
Add table
Reference in a new issue