Compare commits
3 Commits
b25b08b5c5
...
c4f6798fd0
| Author | SHA1 | Date | |
|---|---|---|---|
| c4f6798fd0 | |||
| 130ad8f186 | |||
| 09e4150294 |
@@ -27,7 +27,7 @@ public enum NotificationPushProvider
|
||||
Google
|
||||
}
|
||||
|
||||
[Index(nameof(DeviceToken), nameof(DeviceId), IsUnique = true)]
|
||||
[Index(nameof(DeviceToken), nameof(DeviceId), nameof(AccountId), IsUnique = true)]
|
||||
public class NotificationPushSubscription : ModelBase
|
||||
{
|
||||
public Guid Id { get; set; } = Guid.NewGuid();
|
||||
|
||||
@@ -36,7 +36,6 @@ public class NotificationService(
|
||||
// Reset these audit fields to renew the lifecycle of this device token
|
||||
existingSubscription.DeviceId = deviceId;
|
||||
existingSubscription.DeviceToken = deviceToken;
|
||||
existingSubscription.UpdatedAt = SystemClock.Instance.GetCurrentInstant();
|
||||
db.Update(existingSubscription);
|
||||
await db.SaveChangesAsync();
|
||||
return existingSubscription;
|
||||
|
||||
3394
DysonNetwork.Sphere/Migrations/20250602144445_FixPushNotificationIndex.Designer.cs
generated
Normal file
3394
DysonNetwork.Sphere/Migrations/20250602144445_FixPushNotificationIndex.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,38 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace DysonNetwork.Sphere.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class FixPushNotificationIndex : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropIndex(
|
||||
name: "ix_notification_push_subscriptions_device_token_device_id",
|
||||
table: "notification_push_subscriptions");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_notification_push_subscriptions_device_token_device_id_acco",
|
||||
table: "notification_push_subscriptions",
|
||||
columns: new[] { "device_token", "device_id", "account_id" },
|
||||
unique: true);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropIndex(
|
||||
name: "ix_notification_push_subscriptions_device_token_device_id_acco",
|
||||
table: "notification_push_subscriptions");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_notification_push_subscriptions_device_token_device_id",
|
||||
table: "notification_push_subscriptions",
|
||||
columns: new[] { "device_token", "device_id" },
|
||||
unique: true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,8 @@ namespace DysonNetwork.Sphere.Sticker;
|
||||
[Route("/stickers")]
|
||||
public class StickerController(AppDatabase db, StickerService st) : ControllerBase
|
||||
{
|
||||
private async Task<IActionResult> _CheckStickerPackPermissions(Guid packId, Account.Account currentUser, PublisherMemberRole requiredRole)
|
||||
private async Task<IActionResult> _CheckStickerPackPermissions(Guid packId, Account.Account currentUser,
|
||||
PublisherMemberRole requiredRole)
|
||||
{
|
||||
var pack = await db.StickerPacks
|
||||
.Include(p => p.Publisher)
|
||||
@@ -32,11 +33,21 @@ public class StickerController(AppDatabase db, StickerService st) : ControllerBa
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public async Task<ActionResult<List<StickerPack>>> ListStickerPacks([FromQuery] int offset = 0,
|
||||
[FromQuery] int take = 20)
|
||||
public async Task<ActionResult<List<StickerPack>>> ListStickerPacks(
|
||||
[FromQuery] int offset = 0,
|
||||
[FromQuery] int take = 20,
|
||||
[FromQuery] string? pubName = null
|
||||
)
|
||||
{
|
||||
var totalCount = await db.StickerPacks.CountAsync();
|
||||
Publisher.Publisher? publisher = null;
|
||||
if (pubName is not null)
|
||||
publisher = await db.Publishers.FirstOrDefaultAsync(p => p.Name == pubName);
|
||||
|
||||
var totalCount = await db.StickerPacks
|
||||
.If(publisher is not null, q => q.Where(f => f.PublisherId == publisher!.Id))
|
||||
.CountAsync();
|
||||
var packs = await db.StickerPacks
|
||||
.If(publisher is not null, q => q.Where(f => f.PublisherId == publisher!.Id))
|
||||
.OrderByDescending(e => e.CreatedAt)
|
||||
.Skip(offset)
|
||||
.Take(take)
|
||||
|
||||
@@ -5,6 +5,7 @@ using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using Minio;
|
||||
using Minio.DataModel.Args;
|
||||
using NetVips;
|
||||
using NodaTime;
|
||||
using Quartz;
|
||||
using tusdotnet.Stores;
|
||||
@@ -51,6 +52,7 @@ public class FileService(
|
||||
}
|
||||
|
||||
private static readonly string TempFilePrefix = "dyn-cloudfile";
|
||||
private static readonly string[] function = new[] { "image/gif", "image/apng", "image/webp", "image/avif" };
|
||||
|
||||
// The analysis file method no longer will remove the GPS EXIF data
|
||||
// It should be handled on the client side, and for some specific cases it should be keep
|
||||
@@ -110,7 +112,7 @@ public class FileService(
|
||||
var format = vipsImage.Get("vips-loader") ?? "unknown";
|
||||
|
||||
// Try to get orientation from exif data
|
||||
int orientation = 1;
|
||||
var orientation = 1;
|
||||
Dictionary<string, object> exif = [];
|
||||
|
||||
foreach (var field in vipsImage.GetFields())
|
||||
@@ -177,10 +179,12 @@ public class FileService(
|
||||
if (contentType.Split('/')[0] == "image")
|
||||
{
|
||||
// Skip compression for animated image types
|
||||
var animatedMimeTypes = new[] { "image/gif", "image/apng", "image/webp", "image/avif" };
|
||||
var animatedMimeTypes = function;
|
||||
if (animatedMimeTypes.Contains(contentType))
|
||||
{
|
||||
logger.LogInformation("File {fileId} is an animated image (MIME: {mime}), skipping WebP conversion.", fileId, contentType);
|
||||
logger.LogInformation(
|
||||
"File {fileId} is an animated image (MIME: {mime}), skipping WebP conversion.", fileId,
|
||||
contentType);
|
||||
var tempFilePath = Path.Join(Path.GetTempPath(), $"{TempFilePrefix}#{file.Id}");
|
||||
result.Add((tempFilePath, string.Empty));
|
||||
return;
|
||||
@@ -190,7 +194,8 @@ public class FileService(
|
||||
|
||||
using var vipsImage = NetVips.Image.NewFromFile(ogFilePath);
|
||||
var imagePath = Path.Join(Path.GetTempPath(), $"{TempFilePrefix}#{file.Id}");
|
||||
vipsImage.WriteToFile(imagePath + ".webp");
|
||||
vipsImage.WriteToFile(imagePath + ".webp",
|
||||
new VOption { { "lossless", true } });
|
||||
result.Add((imagePath + ".webp", string.Empty));
|
||||
|
||||
if (vipsImage.Width * vipsImage.Height >= 1024 * 1024)
|
||||
@@ -201,7 +206,8 @@ public class FileService(
|
||||
|
||||
// Create and save image within the same synchronous block to avoid disposal issues
|
||||
using var compressedImage = vipsImage.Resize(scale);
|
||||
compressedImage.WriteToFile(imageCompressedPath + ".webp");
|
||||
compressedImage.WriteToFile(imageCompressedPath + ".webp",
|
||||
new VOption { { "Q", 80 } });
|
||||
|
||||
result.Add((imageCompressedPath + ".webp", ".compressed"));
|
||||
file.HasCompression = true;
|
||||
|
||||
Reference in New Issue
Block a user