diff --git a/Iceshrimp.Backend/Controllers/Federation/ActivityPubController.cs b/Iceshrimp.Backend/Controllers/Federation/ActivityPubController.cs
index e7c17a9f..d68acfa3 100644
--- a/Iceshrimp.Backend/Controllers/Federation/ActivityPubController.cs
+++ b/Iceshrimp.Backend/Controllers/Federation/ActivityPubController.cs
@@ -334,7 +334,7 @@ public class ActivityPubController(
{
Id = emoji.GetPublicUri(config.Value),
Name = emoji.Name,
- Image = new ASImage { Url = new ASLink(emoji.RawPublicUrl) }
+ Image = new ASImage { Url = new ASLink(emoji.RawPublicUrl), MediaType = emoji.Type }
};
return LdHelpers.Compact(rendered);
diff --git a/Iceshrimp.Backend/Core/Database/Migrations/v2025.1-beta5/20250217192617_FixupEmojiType.cs b/Iceshrimp.Backend/Core/Database/Migrations/v2025.1-beta5/20250217192617_FixupEmojiType.cs
new file mode 100644
index 00000000..8a187ece
--- /dev/null
+++ b/Iceshrimp.Backend/Core/Database/Migrations/v2025.1-beta5/20250217192617_FixupEmojiType.cs
@@ -0,0 +1,41 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+
+#nullable disable
+
+namespace Iceshrimp.Backend.Core.Database.Migrations
+{
+ ///
+ [DbContext(typeof(DatabaseContext))]
+ [Migration("20250217192617_FixupEmojiType")]
+ public partial class FixupEmojiType : Migration
+ {
+ ///
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.Sql("""
+ UPDATE "emoji"
+ SET "type" =
+ (SELECT COALESCE("drive_file"."webpublicType", "drive_file"."type")
+ FROM "drive_file"
+ WHERE "drive_file"."userHost" IS NULL
+ AND ("drive_file"."webpublicUrl" = "emoji"."publicUrl"
+ OR "drive_file"."url" = "emoji"."publicUrl"
+ )
+ )
+ WHERE "host" IS NULL
+ AND EXISTS
+ (SELECT 1
+ FROM "drive_file"
+ WHERE "drive_file"."userHost" IS NULL
+ AND ("drive_file"."webpublicUrl" = "emoji"."publicUrl"
+ OR "drive_file"."url" = "emoji"."publicUrl"
+ )
+ );
+ """);
+ }
+
+ ///
+ protected override void Down(MigrationBuilder migrationBuilder) { }
+ }
+}
diff --git a/Iceshrimp.Backend/Core/Federation/ActivityPub/ActivityRenderer.cs b/Iceshrimp.Backend/Core/Federation/ActivityPub/ActivityRenderer.cs
index 5fbf855a..6b7d4b13 100644
--- a/Iceshrimp.Backend/Core/Federation/ActivityPub/ActivityRenderer.cs
+++ b/Iceshrimp.Backend/Core/Federation/ActivityPub/ActivityRenderer.cs
@@ -92,7 +92,7 @@ public class ActivityRenderer(
{
Id = emoji.GetPublicUriOrNull(config.Value),
Name = name,
- Image = new ASImage { Url = new ASLink(emoji.RawPublicUrl) }
+ Image = new ASImage { Url = new ASLink(emoji.RawPublicUrl), MediaType = emoji.Type }
};
res.Tags = [e];
diff --git a/Iceshrimp.Backend/Core/Federation/ActivityPub/NoteRenderer.cs b/Iceshrimp.Backend/Core/Federation/ActivityPub/NoteRenderer.cs
index 3b475146..777c057f 100644
--- a/Iceshrimp.Backend/Core/Federation/ActivityPub/NoteRenderer.cs
+++ b/Iceshrimp.Backend/Core/Federation/ActivityPub/NoteRenderer.cs
@@ -105,7 +105,7 @@ public class NoteRenderer(
{
Id = e.GetPublicUri(config.Value),
Name = e.Name,
- Image = new ASImage { Url = new ASLink(e.RawPublicUrl) }
+ Image = new ASImage { Url = new ASLink(e.RawPublicUrl), MediaType = e.Type }
}))
.ToList();
diff --git a/Iceshrimp.Backend/Core/Federation/ActivityPub/UserRenderer.cs b/Iceshrimp.Backend/Core/Federation/ActivityPub/UserRenderer.cs
index 2d75b8e1..cc30c66b 100644
--- a/Iceshrimp.Backend/Core/Federation/ActivityPub/UserRenderer.cs
+++ b/Iceshrimp.Backend/Core/Federation/ActivityPub/UserRenderer.cs
@@ -74,7 +74,7 @@ public class UserRenderer(
{
Id = e.GetPublicUri(config.Value),
Name = e.Name,
- Image = new ASImage { Url = new ASLink(e.RawPublicUrl) }
+ Image = new ASImage { Url = new ASLink(e.RawPublicUrl), MediaType = e.Type }
}))
.ToList();
diff --git a/Iceshrimp.Backend/Core/Services/EmojiService.cs b/Iceshrimp.Backend/Core/Services/EmojiService.cs
index 3bd65e66..e1b5aa5d 100644
--- a/Iceshrimp.Backend/Core/Services/EmojiService.cs
+++ b/Iceshrimp.Backend/Core/Services/EmojiService.cs
@@ -49,16 +49,17 @@ public partial class EmojiService(
var id = IdHelpers.GenerateSnowflakeId();
var emoji = new Emoji
{
- Id = id,
- Name = name,
- Aliases = aliases ?? [],
- Category = category,
- UpdatedAt = DateTime.UtcNow,
- OriginalUrl = driveFile.Url,
- RawPublicUrl = driveFile.RawAccessUrl,
- Width = driveFile.Properties.Width,
- Height = driveFile.Properties.Height,
- Sensitive = false
+ Id = id,
+ Name = name,
+ Aliases = aliases ?? [],
+ Category = category,
+ UpdatedAt = DateTime.UtcNow,
+ OriginalUrl = driveFile.Url,
+ RawPublicUrl = driveFile.RawAccessUrl,
+ Type = driveFile.PublicMimeType ?? driveFile.Type,
+ Width = driveFile.Properties.Width,
+ Height = driveFile.Properties.Height,
+ Sensitive = false
};
emoji.Uri = emoji.GetPublicUri(config.Value);
@@ -77,14 +78,15 @@ public partial class EmojiService(
var emoji = new Emoji
{
- Id = IdHelpers.GenerateSnowflakeId(),
- Name = existing.Name,
- UpdatedAt = DateTime.UtcNow,
- OriginalUrl = driveFile.Url,
- RawPublicUrl = driveFile.RawAccessUrl,
- Width = driveFile.Properties.Width,
- Height = driveFile.Properties.Height,
- Sensitive = existing.Sensitive
+ Id = IdHelpers.GenerateSnowflakeId(),
+ Name = existing.Name,
+ UpdatedAt = DateTime.UtcNow,
+ OriginalUrl = driveFile.Url,
+ RawPublicUrl = driveFile.RawAccessUrl,
+ Type = driveFile.PublicMimeType ?? driveFile.Type,
+ Width = driveFile.Properties.Width,
+ Height = driveFile.Properties.Height,
+ Sensitive = existing.Sensitive
};
emoji.Uri = emoji.GetPublicUri(config.Value);
@@ -127,14 +129,15 @@ public partial class EmojiService(
{
dbEmojo = new Emoji
{
- Id = IdHelpers.GenerateSnowflakeId(),
- Host = host,
- Name = emojo.Name ?? throw new Exception("emojo.Name must not be null at this stage"),
- UpdatedAt = DateTime.UtcNow,
- OriginalUrl = emojo.Image?.Url?.Link ?? throw new Exception("Emoji.Image has no url"),
- RawPublicUrl = emojo.Image.Url.Link,
- Uri = emojo.Id,
- Sensitive = false
+ Id = IdHelpers.GenerateSnowflakeId(),
+ Host = host,
+ Name = emojo.Name ?? throw new Exception("emojo.Name must not be null at this stage"),
+ UpdatedAt = DateTime.UtcNow,
+ OriginalUrl = emojo.Image?.Url?.Link ?? throw new Exception("Emoji.Image has no url"),
+ RawPublicUrl = emojo.Image.Url.Link,
+ Type = emojo.Image.MediaType,
+ Uri = emojo.Id,
+ Sensitive = false
};
await db.AddAsync(dbEmojo);
await db.SaveChangesAsync();